mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-14 00:58:38 +02:00
avcodec/tdsc: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
b0de31e278
commit
6ef104cb5f
@ -53,6 +53,7 @@ typedef struct TDSCContext {
|
|||||||
GetByteContext gbc;
|
GetByteContext gbc;
|
||||||
|
|
||||||
AVFrame *refframe; // full decoded frame (without cursor)
|
AVFrame *refframe; // full decoded frame (without cursor)
|
||||||
|
AVPacket *jpkt; // encoded JPEG tile
|
||||||
AVFrame *jpgframe; // decoded JPEG tile
|
AVFrame *jpgframe; // decoded JPEG tile
|
||||||
uint8_t *tilebuffer; // buffer containing tile data
|
uint8_t *tilebuffer; // buffer containing tile data
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ static av_cold int tdsc_close(AVCodecContext *avctx)
|
|||||||
|
|
||||||
av_frame_free(&ctx->refframe);
|
av_frame_free(&ctx->refframe);
|
||||||
av_frame_free(&ctx->jpgframe);
|
av_frame_free(&ctx->jpgframe);
|
||||||
|
av_packet_free(&ctx->jpkt);
|
||||||
av_freep(&ctx->deflatebuffer);
|
av_freep(&ctx->deflatebuffer);
|
||||||
av_freep(&ctx->tilebuffer);
|
av_freep(&ctx->tilebuffer);
|
||||||
av_freep(&ctx->cursor);
|
av_freep(&ctx->cursor);
|
||||||
@ -111,7 +113,8 @@ static av_cold int tdsc_init(AVCodecContext *avctx)
|
|||||||
/* Allocate reference and JPEG frame */
|
/* Allocate reference and JPEG frame */
|
||||||
ctx->refframe = av_frame_alloc();
|
ctx->refframe = av_frame_alloc();
|
||||||
ctx->jpgframe = av_frame_alloc();
|
ctx->jpgframe = av_frame_alloc();
|
||||||
if (!ctx->refframe || !ctx->jpgframe)
|
ctx->jpkt = av_packet_alloc();
|
||||||
|
if (!ctx->refframe || !ctx->jpgframe || !ctx->jpkt)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
/* Prepare everything needed for JPEG decoding */
|
/* Prepare everything needed for JPEG decoding */
|
||||||
@ -342,15 +345,14 @@ static int tdsc_decode_jpeg_tile(AVCodecContext *avctx, int tile_size,
|
|||||||
int x, int y, int w, int h)
|
int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
TDSCContext *ctx = avctx->priv_data;
|
TDSCContext *ctx = avctx->priv_data;
|
||||||
AVPacket jpkt;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Prepare a packet and send to the MJPEG decoder */
|
/* Prepare a packet and send to the MJPEG decoder */
|
||||||
av_init_packet(&jpkt);
|
av_packet_unref(ctx->jpkt);
|
||||||
jpkt.data = ctx->tilebuffer;
|
ctx->jpkt->data = ctx->tilebuffer;
|
||||||
jpkt.size = tile_size;
|
ctx->jpkt->size = tile_size;
|
||||||
|
|
||||||
ret = avcodec_send_packet(ctx->jpeg_avctx, &jpkt);
|
ret = avcodec_send_packet(ctx->jpeg_avctx, ctx->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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user