summaryrefslogtreecommitdiff
path: root/libavformat/omadec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-07-29 12:21:08 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-07-29 12:21:52 +0200
commitbc672a016fa16ed678f1f324b9b5adf0bacd4ac8 (patch)
treef2e01fa25be9fcf0645cf63518a9eb13a9143465 /libavformat/omadec.c
parent6561aae8a955b9237034a004fc92d7fbb3541491 (diff)
parent4f03a77e52596cbe9ec179666ddb3e0345a8133a (diff)
downloadffmpeg-bc672a016fa16ed678f1f324b9b5adf0bacd4ac8.tar.gz
Merge commit '4f03a77e52596cbe9ec179666ddb3e0345a8133a'
* commit '4f03a77e52596cbe9ec179666ddb3e0345a8133a': oma: refactor seek function Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/omadec.c')
-rw-r--r--libavformat/omadec.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index e571495c8d..f3d9790ac5 100644
--- a/libavformat/omadec.c
+++ b/libavformat/omadec.c
@@ -449,24 +449,26 @@ static int oma_read_seek(struct AVFormatContext *s,
int stream_index, int64_t timestamp, int flags)
{
OMAContext *oc = s->priv_data;
-
- ff_pcm_read_seek(s, stream_index, timestamp, flags);
-
- if (oc->encrypted) {
- /* readjust IV for CBC */
- int64_t pos = avio_tell(s->pb);
- if (pos < oc->content_start)
- memset(oc->iv, 0, 8);
- else {
- if (avio_seek(s->pb, -8, SEEK_CUR) < 0 ||
- avio_read(s->pb, oc->iv, 8) < 8) {
- memset(oc->iv, 0, 8);
- return -1;
- }
- }
+ int err = ff_pcm_read_seek(s, stream_index, timestamp, flags);
+
+ if (!oc->encrypted)
+ return err;
+
+ /* readjust IV for CBC */
+ if (err || avio_tell(s->pb) < oc->content_start)
+ goto wipe;
+ if ((err = avio_seek(s->pb, -8, SEEK_CUR)) < 0)
+ goto wipe;
+ if ((err = avio_read(s->pb, oc->iv, 8)) < 8) {
+ if (err >= 0)
+ err = AVERROR_EOF;
+ goto wipe;
}
return 0;
+wipe:
+ memset(oc->iv, 0, 8);
+ return err;
}
AVInputFormat ff_oma_demuxer = {