]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/paf.c
vda: merge implementation into one file.
[ffmpeg] / libavcodec / paf.c
index 0d982d9423d855ead25c6271f5746b28f6902219..1c3e8b8fcd71726c070c958627fbe5df3db9ca42 100644 (file)
@@ -164,14 +164,16 @@ static int decode_0(AVCodecContext *avctx, uint8_t code, uint8_t *pkt)
         } while (--i);
     }
 
-    dst = c->frame[c->current_frame];
+    dst  = c->frame[c->current_frame];
+    dend = c->frame[c->current_frame] + c->frame_size;
     do {
         a    = bytestream2_get_byte(&c->gb);
         b    = bytestream2_get_byte(&c->gb);
         p    = (a & 0xC0) >> 6;
         src  = c->frame[p] + get_video_page_offset(avctx, a, b);
         send = c->frame[p] + c->frame_size;
-        if (src + 3 * avctx->width + 4 > send)
+        if ((src + 3 * avctx->width + 4 > send) ||
+            (dst + 3 * avctx->width + 4 > dend))
             return AVERROR_INVALIDDATA;
         copy_block4(dst, src, avctx->width, avctx->width, 4);
         i++;
@@ -247,11 +249,8 @@ static int paf_vid_decode(AVCodecContext *avctx, void *data,
     uint8_t code, *dst, *src, *end;
     int i, frame, ret;
 
-    if (c->pic.data[0])
-        avctx->release_buffer(avctx, &c->pic);
-
-    c->pic.reference = 0;
-    if ((ret = avctx->get_buffer(avctx, &c->pic)) < 0)
+    c->pic.reference = 3;
+    if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0)
         return ret;
 
     bytestream2_init(&c->gb, pkt->data, pkt->size);
@@ -434,7 +433,7 @@ static int paf_aud_decode(AVCodecContext *avctx, void *data,
 AVCodec ff_paf_video_decoder = {
     .name           = "paf_video",
     .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = CODEC_ID_PAF_VIDEO,
+    .id             = AV_CODEC_ID_PAF_VIDEO,
     .priv_data_size = sizeof(PAFVideoDecContext),
     .init           = paf_vid_init,
     .close          = paf_vid_close,
@@ -446,7 +445,7 @@ AVCodec ff_paf_video_decoder = {
 AVCodec ff_paf_audio_decoder = {
     .name           = "paf_audio",
     .type           = AVMEDIA_TYPE_AUDIO,
-    .id             = CODEC_ID_PAF_AUDIO,
+    .id             = AV_CODEC_ID_PAF_AUDIO,
     .priv_data_size = sizeof(PAFAudioDecContext),
     .init           = paf_aud_init,
     .decode         = paf_aud_decode,