You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
lavc/mjpegdec: simplify smvjpeg_receive_frame()
Unify the code for returning the first and every subsequent frame in a packet.
This commit is contained in:
@@ -3023,26 +3023,20 @@ static int smvjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame)
|
|||||||
{
|
{
|
||||||
MJpegDecodeContext *s = avctx->priv_data;
|
MJpegDecodeContext *s = avctx->priv_data;
|
||||||
AVPacket *const pkt = avctx->internal->in_pkt;
|
AVPacket *const pkt = avctx->internal->in_pkt;
|
||||||
int64_t pkt_dts;
|
|
||||||
int got_frame = 0;
|
int got_frame = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (s->smv_next_frame > 0) {
|
if (s->smv_next_frame > 0)
|
||||||
av_assert0(s->smv_frame->buf[0]);
|
goto return_frame;
|
||||||
ret = av_frame_ref(frame, s->smv_frame);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
smv_process_frame(avctx, frame);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ff_decode_get_packet(avctx, pkt);
|
ret = ff_decode_get_packet(avctx, pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = ff_mjpeg_decode_frame(avctx, frame, &got_frame, pkt);
|
av_frame_unref(s->smv_frame);
|
||||||
pkt_dts = pkt->dts;
|
|
||||||
|
ret = ff_mjpeg_decode_frame(avctx, s->smv_frame, &got_frame, pkt);
|
||||||
|
s->smv_frame->pkt_dts = pkt->dts;
|
||||||
av_packet_unref(pkt);
|
av_packet_unref(pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -3050,11 +3044,9 @@ static int smvjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame)
|
|||||||
if (!got_frame)
|
if (!got_frame)
|
||||||
return AVERROR(EAGAIN);
|
return AVERROR(EAGAIN);
|
||||||
|
|
||||||
frame->pkt_dts = pkt_dts;
|
return_frame:
|
||||||
|
av_assert0(s->smv_frame->buf[0]);
|
||||||
av_assert0(frame->buf[0]);
|
ret = av_frame_ref(frame, s->smv_frame);
|
||||||
av_frame_unref(s->smv_frame);
|
|
||||||
ret = av_frame_ref(s->smv_frame, frame);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user