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
5858
5959 /* JPEG decoding for DNG */
6060 AVCodecContext *avctx_mjpeg; // wrapper context for MJPEG
61+ AVPacket *jpkt; // encoded JPEG tile
6162 AVFrame *jpgframe; // decoded JPEG tile
6263
6364 int get_subimage;
@@ -877,7 +878,6 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame, · 813 unmodified lines
877878 int tile_byte_count, int dst_x, int dst_y, int w, int h)
878879 {
879880 TiffContext *s = avctx->priv_data;
880− AVPacket jpkt;
881881 uint8_t *dst_data, *src_data;
882882 uint32_t dst_offset; /* offset from dst buffer in pixels */
883883 int is_single_comp, is_u16, pixel_size;
@@ -887,9 +887,9 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame, · 3 unmodified lines
887887 return AVERROR_INVALIDDATA;
888888
889889 /* Prepare a packet and send to the MJPEG decoder */
890− av_init_packet(&jpkt);
891− jpkt.data = (uint8_t*)s->gb.buffer;
892− jpkt.size = tile_byte_count;
890+ av_packet_unref(s->jpkt);
891+ s->jpkt->data = (uint8_t*)s->gb.buffer;
892+ s->jpkt->size = tile_byte_count;
893893
894894 if (s->is_bayer) {
895895 MJpegDecodeContext *mjpegdecctx = s->avctx_mjpeg->priv_data;
@@ -898,7 +898,7 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame, · 2 unmodified lines
898898 mjpegdecctx->bayer = 1;
899899 }
900900
901− ret = avcodec_send_packet(s->avctx_mjpeg, &jpkt);
901+ ret = avcodec_send_packet(s->avctx_mjpeg, s->jpkt);
902902 if (ret < 0) {
903903 av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
904904 return ret;
@@ -2158,7 +2158,8 @@ static av_cold int tiff_init(AVCodecContext *avctx) · 1253 unmodified lines
21582158
21592159 /* Allocate JPEG frame */
21602160 s->jpgframe = av_frame_alloc();
2161− if (!s->jpgframe)
2161+ s->jpkt = av_packet_alloc();
2162+ if (!s->jpgframe || !s->jpkt)
21622163 return AVERROR(ENOMEM);
21632164
21642165 /* Prepare everything needed for JPEG decoding */
@@ -2194,6 +2195,7 @@ static av_cold int tiff_end(AVCodecContext *avctx) · 29 unmodified lines
21942195 av_freep(&s->fax_buffer);
21952196 s->fax_buffer_size = 0;
21962197 av_frame_free(&s->jpgframe);
2198+ av_packet_free(&s->jpkt);
21972199 avcodec_free_context(&s->avctx_mjpeg);
21982200 return 0;
21992201 }

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