Unified · Split
| @@ -58,6 +58,7 @@ typedef struct TiffContext { · 57 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | /* JPEG decoding for DNG */ |
| 60 | 60 | AVCodecContext *avctx_mjpeg; // wrapper context for MJPEG |
| 61 | + AVPacket *jpkt; // encoded JPEG tile | |
| 61 | 62 | AVFrame *jpgframe; // decoded JPEG tile |
| 62 | 63 | |
| 63 | 64 | int get_subimage; |
| @@ -877,7 +878,6 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame, · 813 unmodified lines | ||
| 877 | 878 | int tile_byte_count, int dst_x, int dst_y, int w, int h) |
| 878 | 879 | { |
| 879 | 880 | TiffContext *s = avctx->priv_data; |
| 880 | − AVPacket jpkt; | |
| 881 | 881 | uint8_t *dst_data, *src_data; |
| 882 | 882 | uint32_t dst_offset; /* offset from dst buffer in pixels */ |
| 883 | 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 | 887 | return AVERROR_INVALIDDATA; |
| 888 | 888 | |
| 889 | 889 | /* 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; | |
| 893 | 893 | |
| 894 | 894 | if (s->is_bayer) { |
| 895 | 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 | 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 | 902 | if (ret < 0) { |
| 903 | 903 | av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n"); |
| 904 | 904 | return ret; |
| @@ -2158,7 +2158,8 @@ static av_cold int tiff_init(AVCodecContext *avctx) · 1253 unmodified lines | ||
| 2158 | 2158 | |
| 2159 | 2159 | /* Allocate JPEG frame */ |
| 2160 | 2160 | s->jpgframe = av_frame_alloc(); |
| 2161 | − if (!s->jpgframe) | |
| 2161 | + s->jpkt = av_packet_alloc(); | |
| 2162 | + if (!s->jpgframe || !s->jpkt) | |
| 2162 | 2163 | return AVERROR(ENOMEM); |
| 2163 | 2164 | |
| 2164 | 2165 | /* Prepare everything needed for JPEG decoding */ |
| @@ -2194,6 +2195,7 @@ static av_cold int tiff_end(AVCodecContext *avctx) · 29 unmodified lines | ||
| 2194 | 2195 | av_freep(&s->fax_buffer); |
| 2195 | 2196 | s->fax_buffer_size = 0; |
| 2196 | 2197 | av_frame_free(&s->jpgframe); |
| 2198 | + av_packet_free(&s->jpkt); | |
| 2197 | 2199 | avcodec_free_context(&s->avctx_mjpeg); |
| 2198 | 2200 | return 0; |
| 2199 | 2201 | } |