Merge commit '759001c534287a96dc96d1e274665feb7059145d'
[ffmpeg.git] / libavcodec / j2kdec.c
index 53c4f07..fef0348 100644 (file)
@@ -49,7 +49,7 @@ typedef struct {
 
 typedef struct {
     AVCodecContext *avctx;
-    AVFrame picture;
+    AVFrame *picture;
     GetByteContext g;
 
     int width, height; ///< image width and height
@@ -281,14 +281,12 @@ static int get_siz(J2kDecoderContext *s)
         break;
     }
 
-    if (s->picture.data[0])
-        s->avctx->release_buffer(s->avctx, &s->picture);
 
-    if ((ret = ff_get_buffer(s->avctx, &s->picture)) < 0)
+    if ((ret = ff_get_buffer(s->avctx, s->picture, 0)) < 0)
         return ret;
 
-    s->picture.pict_type = AV_PICTURE_TYPE_I;
-    s->picture.key_frame = 1;
+    s->picture->pict_type = AV_PICTURE_TYPE_I;
+    s->picture->key_frame = 1;
 
     return 0;
 }
@@ -859,7 +857,7 @@ static int decode_tile(J2kDecoderContext *s, J2kTile *tile)
     if (s->precision <= 8) {
         for (compno = 0; compno < s->ncomponents; compno++){
             y = tile->comp[compno].coord[1][0] - s->image_offset_y;
-            line = s->picture.data[0] + y * s->picture.linesize[0];
+            line = s->picture->data[0] + y * s->picture->linesize[0];
             for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]){
                 uint8_t *dst;
 
@@ -875,13 +873,13 @@ static int decode_tile(J2kDecoderContext *s, J2kTile *tile)
                     *dst = *src[compno]++;
                     dst += s->ncomponents;
                 }
-                line += s->picture.linesize[0];
+                line += s->picture->linesize[0];
             }
         }
     } else {
         for (compno = 0; compno < s->ncomponents; compno++) {
             y = tile->comp[compno].coord[1][0] - s->image_offset_y;
-            line = s->picture.data[0] + y * s->picture.linesize[0];
+            line = s->picture->data[0] + y * s->picture->linesize[0];
             for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
                 uint16_t *dst;
 
@@ -896,7 +894,7 @@ static int decode_tile(J2kDecoderContext *s, J2kTile *tile)
                     *dst = val;
                     dst += s->ncomponents;
                 }
-                line += s->picture.linesize[0];
+                line += s->picture->linesize[0];
             }
         }
     }
@@ -1025,6 +1023,8 @@ static int decode_frame(AVCodecContext *avctx,
     AVFrame *picture = data;
     int tileno, ret;
 
+    s->picture = picture;
+
     bytestream2_init(&s->g, avpkt->data, avpkt->size);
     s->curtileno = -1;
 
@@ -1062,7 +1062,6 @@ static int decode_frame(AVCodecContext *avctx,
     cleanup(s);
 
     *got_frame = 1;
-    *picture = s->picture;
 
     return bytestream2_tell(&s->g);
 
@@ -1076,8 +1075,6 @@ static av_cold int j2kdec_init(AVCodecContext *avctx)
     J2kDecoderContext *s = avctx->priv_data;
 
     s->avctx = avctx;
-    avcodec_get_frame_defaults((AVFrame*)&s->picture);
-    avctx->coded_frame = (AVFrame*)&s->picture;
 
     ff_j2k_init_tier1_luts();
 
@@ -1088,9 +1085,6 @@ static av_cold int decode_end(AVCodecContext *avctx)
 {
     J2kDecoderContext *s = avctx->priv_data;
 
-    if (s->picture.data[0])
-        avctx->release_buffer(avctx, &s->picture);
-
     return 0;
 }