History

avcodec/tiff: use av_packet_alloc() to allocate AVPackets

James Almer committed 5 years ago

Commit fc2e0221 parent 6ef104c1 file · +8 −6Browse files

Unified · Split

libavcodec/tiff.c+8−6
@@ -58,6 +58,7 @@ typedef struct TiffContext { · 57 unmodified lines
58 58
59 /* JPEG decoding for DNG */59 /* JPEG decoding for DNG */
60 AVCodecContext *avctx_mjpeg; // wrapper context for MJPEG60 AVCodecContext *avctx_mjpeg; // wrapper context for MJPEG
61 AVPacket *jpkt; // encoded JPEG tile
61 AVFrame *jpgframe; // decoded JPEG tile62 AVFrame *jpgframe; // decoded JPEG tile
62 63
63 int get_subimage;64 int get_subimage;
@@ -877,7 +878,6 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame, · 813 unmodified lines
877 int tile_byte_count, int dst_x, int dst_y, int w, int h)878 int tile_byte_count, int dst_x, int dst_y, int w, int h)
878{879{
879 TiffContext *s = avctx->priv_data;880 TiffContext *s = avctx->priv_data;
880 AVPacket jpkt;
881 uint8_t *dst_data, *src_data;881 uint8_t *dst_data, *src_data;
882 uint32_t dst_offset; /* offset from dst buffer in pixels */882 uint32_t dst_offset; /* offset from dst buffer in pixels */
883 int is_single_comp, is_u16, pixel_size;883 int is_single_comp, is_u16, pixel_size;
@@ -887,9 +887,9 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame, · 3 unmodified lines
887 return AVERROR_INVALIDDATA;887 return AVERROR_INVALIDDATA;
888 888
889 /* Prepare a packet and send to the MJPEG decoder */889 /* Prepare a packet and send to the MJPEG decoder */
890 av_init_packet(&jpkt);890 av_packet_unref(s->jpkt);
891 jpkt.data = (uint8_t*)s->gb.buffer;891 s->jpkt->data = (uint8_t*)s->gb.buffer;
892 jpkt.size = tile_byte_count;892 s->jpkt->size = tile_byte_count;
893 893
894 if (s->is_bayer) {894 if (s->is_bayer) {
895 MJpegDecodeContext *mjpegdecctx = s->avctx_mjpeg->priv_data;895 MJpegDecodeContext *mjpegdecctx = s->avctx_mjpeg->priv_data;
@@ -898,7 +898,7 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame, · 2 unmodified lines
898 mjpegdecctx->bayer = 1;898 mjpegdecctx->bayer = 1;
899 }899 }
900 900
901 ret = avcodec_send_packet(s->avctx_mjpeg, &jpkt);901 ret = avcodec_send_packet(s->avctx_mjpeg, s->jpkt);
902 if (ret < 0) {902 if (ret < 0) {
903 av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n");903 av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
904 return ret;904 return ret;
@@ -2158,7 +2158,8 @@ static av_cold int tiff_init(AVCodecContext *avctx) · 1253 unmodified lines
2158 2158
2159 /* Allocate JPEG frame */2159 /* Allocate JPEG frame */
2160 s->jpgframe = av_frame_alloc();2160 s->jpgframe = av_frame_alloc();
2161 if (!s->jpgframe)2161 s->jpkt = av_packet_alloc();
2162 if (!s->jpgframe || !s->jpkt)
2162 return AVERROR(ENOMEM);2163 return AVERROR(ENOMEM);
2163 2164
2164 /* Prepare everything needed for JPEG decoding */2165 /* Prepare everything needed for JPEG decoding */
@@ -2194,6 +2195,7 @@ static av_cold int tiff_end(AVCodecContext *avctx) · 29 unmodified lines
2194 av_freep(&s->fax_buffer);2195 av_freep(&s->fax_buffer);
2195 s->fax_buffer_size = 0;2196 s->fax_buffer_size = 0;
2196 av_frame_free(&s->jpgframe);2197 av_frame_free(&s->jpgframe);
2198 av_packet_free(&s->jpkt);
2197 avcodec_free_context(&s->avctx_mjpeg);2199 avcodec_free_context(&s->avctx_mjpeg);
2198 return 0;2200 return 0;
2199}2201}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t