X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fsp5xdec.c;h=302fdb073e768ef95b3de4616d041cbdcf192fd1;hb=e9a2a8777317d91af658f774c68442ac4aa726ec;hp=815f9ad50ea4a896c537dd4d571b37a8792890dd;hpb=ee96ab2db507b95a694f10b152481cf71842de28;p=ffmpeg diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 815f9ad50ea..302fdb073e7 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -30,14 +30,11 @@ #include "mjpegdec.h" #include "sp5x.h" - -static int sp5x_decode_frame(AVCodecContext *avctx, - void *data, int *got_frame, - AVPacket *avpkt) +int ff_sp5x_process_packet(AVCodecContext *avctx, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - AVPacket avpkt_recoded; + AVBufferRef *buf_recoded; const int qscale = 5; uint8_t *recoded; int i = 0, j = 0; @@ -45,9 +42,10 @@ static int sp5x_decode_frame(AVCodecContext *avctx, if (!avctx->width || !avctx->height) return -1; - recoded = av_mallocz(buf_size + 1024); - if (!recoded) + buf_recoded = av_buffer_allocz(buf_size + 1024); + if (!buf_recoded) return -1; + recoded = buf_recoded->data; /* SOI */ recoded[j++] = 0xFF; @@ -84,14 +82,12 @@ static int sp5x_decode_frame(AVCodecContext *avctx, recoded[j++] = 0xFF; recoded[j++] = 0xD9; - av_init_packet(&avpkt_recoded); - avpkt_recoded.data = recoded; - avpkt_recoded.size = j; - i = ff_mjpeg_decode_frame(avctx, data, got_frame, &avpkt_recoded); - - av_free(recoded); + av_buffer_unref(&avpkt->buf); + avpkt->buf = buf_recoded; + avpkt->data = recoded; + avpkt->size = j; - return i < 0 ? i : avpkt->size; + return 0; } #if CONFIG_SP5X_DECODER @@ -103,10 +99,11 @@ AVCodec ff_sp5x_decoder = { .priv_data_size = sizeof(MJpegDecodeContext), .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, - .decode = sp5x_decode_frame, + .receive_frame = ff_mjpeg_receive_frame, .capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_SETS_PKT_DTS, }; #endif #if CONFIG_AMV_DECODER @@ -118,9 +115,10 @@ AVCodec ff_amv_decoder = { .priv_data_size = sizeof(MJpegDecodeContext), .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, - .decode = sp5x_decode_frame, + .receive_frame = ff_mjpeg_receive_frame, .max_lowres = 3, .capabilities = AV_CODEC_CAP_DR1, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_SETS_PKT_DTS, }; #endif