summaryrefslogtreecommitdiff
path: root/libavcodec/sp5xdec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-12-01 11:34:27 +0100
committerAnton Khirnov <anton@khirnov.net>2020-12-10 10:03:58 +0100
commite9a2a8777317d91af658f774c68442ac4aa726ec (patch)
tree9fc7b3dd43caabd8b891534f37928225c852e3c6 /libavcodec/sp5xdec.c
parent36237ac4ee874452dd1d8d7439a224a371759ea0 (diff)
mjpegdec: convert to receive_frame()
This will be useful in the following commit.
Diffstat (limited to 'libavcodec/sp5xdec.c')
-rw-r--r--libavcodec/sp5xdec.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c
index ad2e9b11a9..302fdb073e 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 | FF_CODEC_CAP_INIT_CLEANUP,
+ .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 | FF_CODEC_CAP_INIT_CLEANUP,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP |
+ FF_CODEC_CAP_SETS_PKT_DTS,
};
#endif