summaryrefslogtreecommitdiff
path: root/libavformat/wavdec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-12-01 19:32:00 +0100
committerAnton Khirnov <anton@khirnov.net>2020-12-10 10:07:09 +0100
commit19ce06423964627d553c7ee602fd5c73ca4b2135 (patch)
tree7f04a8f1b6952d4d9005e2b064989e83e701a2b6 /libavformat/wavdec.c
parente9a2a8777317d91af658f774c68442ac4aa726ec (diff)
smvjpegdec: merge into mjpegdec
SMVJPEG stores frames as slices of a big JPEG image. The decoder is implemented as a wrapper that instantiates a full internal MJPEG decoder, then forwards the decoded frames with offset data pointers. This is unnecessarily complex and fragile, not supporting useful decoder capabilities like direct rendering. Re-implement the decoder inside the MJPEG decoder, which is accomplished by returning each decoded frame multiple times, setting cropping information appropriately on each instance. One peculiar aspect of the previous design is that since - the smvjpeg decoder returns one frame per input packet - there are multiple frames in each packets (the aformentioned slices) the demuxer needs to return each packet multiple times. This is now also eliminated - the demuxer now returns each packet exactly once, with the duration set to the number of frames it decodes to. This also removes one of the last remaining internal uses of the old video decoding API.
Diffstat (limited to 'libavformat/wavdec.c')
-rw-r--r--libavformat/wavdec.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 67ab620347..35c5e442a8 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -58,7 +58,6 @@ typedef struct WAVDemuxContext {
int ignore_length;
int max_size;
int spdif;
- int smv_cur_pt;
int smv_given_first;
int unaligned; // e.g. if an odd number of bytes ID3 tag was prepended
int rifx; // RIFX: integer byte order for parameters is big endian
@@ -497,7 +496,6 @@ static int wav_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
AV_WL32(vst->codecpar->extradata, wav->smv_frames_per_jpeg);
- wav->smv_cur_pt = 0;
goto break_loop;
case MKTAG('L', 'I', 'S', 'T'):
case MKTAG('l', 'i', 's', 't'):
@@ -717,12 +715,9 @@ smv_retry:
if (ret < 0)
goto smv_out;
pkt->pos -= 3;
- pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt;
- wav->smv_cur_pt++;
- if (wav->smv_frames_per_jpeg > 0)
- wav->smv_cur_pt %= wav->smv_frames_per_jpeg;
- if (!wav->smv_cur_pt)
- wav->smv_block++;
+ pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg;
+ pkt->duration = wav->smv_frames_per_jpeg;
+ wav->smv_block++;
pkt->stream_index = 1;
smv_out:
@@ -784,7 +779,6 @@ static int wav_read_seek(AVFormatContext *s,
timestamp = av_rescale_q(smv_timestamp, s->streams[1]->time_base, s->streams[0]->time_base);
if (wav->smv_frames_per_jpeg > 0) {
wav->smv_block = smv_timestamp / wav->smv_frames_per_jpeg;
- wav->smv_cur_pt = smv_timestamp % wav->smv_frames_per_jpeg;
}
}