mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-02 20:35:37 +02:00
avcodec/cri: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
d422b2ed87
commit
1f32e91df6
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
typedef struct CRIContext {
|
typedef struct CRIContext {
|
||||||
AVCodecContext *jpeg_avctx; // wrapper context for MJPEG
|
AVCodecContext *jpeg_avctx; // wrapper context for MJPEG
|
||||||
|
AVPacket *jpkt; // encoded JPEG tile
|
||||||
AVFrame *jpgframe; // decoded JPEG tile
|
AVFrame *jpgframe; // decoded JPEG tile
|
||||||
|
|
||||||
GetByteContext gb;
|
GetByteContext gb;
|
||||||
@ -56,6 +57,10 @@ static av_cold int cri_decode_init(AVCodecContext *avctx)
|
|||||||
if (!s->jpgframe)
|
if (!s->jpgframe)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
s->jpkt = av_packet_alloc();
|
||||||
|
if (!s->jpkt)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
|
codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
|
||||||
if (!codec)
|
if (!codec)
|
||||||
return AVERROR_BUG;
|
return AVERROR_BUG;
|
||||||
@ -345,13 +350,11 @@ skip:
|
|||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
|
|
||||||
for (int tile = 0; tile < 4; tile++) {
|
for (int tile = 0; tile < 4; tile++) {
|
||||||
AVPacket jpkt;
|
av_packet_unref(s->jpkt);
|
||||||
|
s->jpkt->data = (uint8_t *)s->data + offset;
|
||||||
|
s->jpkt->size = s->tile_size[tile];
|
||||||
|
|
||||||
av_init_packet(&jpkt);
|
ret = avcodec_send_packet(s->jpeg_avctx, s->jpkt);
|
||||||
jpkt.data = (uint8_t *)s->data + offset;
|
|
||||||
jpkt.size = s->tile_size[tile];
|
|
||||||
|
|
||||||
ret = avcodec_send_packet(s->jpeg_avctx, &jpkt);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
|
av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
|
||||||
return ret;
|
return ret;
|
||||||
@ -415,6 +418,7 @@ static av_cold int cri_decode_close(AVCodecContext *avctx)
|
|||||||
CRIContext *s = avctx->priv_data;
|
CRIContext *s = avctx->priv_data;
|
||||||
|
|
||||||
av_frame_free(&s->jpgframe);
|
av_frame_free(&s->jpgframe);
|
||||||
|
av_packet_free(&s->jpkt);
|
||||||
avcodec_free_context(&s->jpeg_avctx);
|
avcodec_free_context(&s->jpeg_avctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user