]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rawdec.c
nvenc: drop the hard dependency on CUDA
[ffmpeg] / libavcodec / rawdec.c
index 66265ced50687241d49131b6bc3b02f953c385ce..284c3451d0654e0cb002e342b8267e8b43b6c4a8 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include "avcodec.h"
+#include "internal.h"
 #include "raw.h"
 #include "libavutil/buffer.h"
 #include "libavutil/common.h"
@@ -108,8 +109,10 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
             memset(context->palette->data, 0, AVPALETTE_SIZE);
     }
 
-    context->frame_size = avpicture_get_size(avctx->pix_fmt, avctx->width,
-                                             avctx->height);
+    context->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
+                                                   avctx->width,
+                                                   avctx->height, 1);
+
     if ((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
         avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
        (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' ')))
@@ -128,10 +131,10 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
     return 0;
 }
 
-static void flip(AVCodecContext *avctx, AVPicture *picture)
+static void flip(AVCodecContext *avctx, AVFrame *frame)
 {
-    picture->data[0]     += picture->linesize[0] * (avctx->height - 1);
-    picture->linesize[0] *= -1;
+    frame->data[0]     += frame->linesize[0] * (avctx->height - 1);
+    frame->linesize[0] *= -1;
 }
 
 static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
@@ -145,12 +148,13 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
     int res;
 
     AVFrame   *frame   = data;
-    AVPicture *picture = data;
 
     frame->pict_type        = AV_PICTURE_TYPE_I;
     frame->key_frame        = 1;
-    frame->reordered_opaque = avctx->reordered_opaque;
-    frame->pkt_pts          = avctx->pkt->pts;
+
+    res = ff_decode_frame_props(avctx, frame);
+    if (res < 0)
+        return res;
 
     if (buf_size < context->frame_size - (avctx->pix_fmt == AV_PIX_FMT_PAL8 ?
                                           AVPALETTE_SIZE : 0))
@@ -191,8 +195,9 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
         avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
         buf += buf_size - context->frame_size;
 
-    if ((res = avpicture_fill(picture, buf, avctx->pix_fmt,
-                              avctx->width, avctx->height)) < 0)
+    if ((res = av_image_fill_arrays(frame->data, frame->linesize,
+                                    buf, avctx->pix_fmt,
+                                    avctx->width, avctx->height, 1)) < 0)
         return res;
 
     if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
@@ -221,22 +226,22 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
         frame->linesize[0] = (frame->linesize[0] + 3) & ~3;
 
     if (context->flip)
-        flip(avctx, picture);
+        flip(avctx, frame);
 
     if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2') ||
         avctx->codec_tag == MKTAG('Y', 'V', '1', '6') ||
         avctx->codec_tag == MKTAG('Y', 'V', '2', '4') ||
         avctx->codec_tag == MKTAG('Y', 'V', 'U', '9'))
-        FFSWAP(uint8_t *, picture->data[1], picture->data[2]);
+        FFSWAP(uint8_t *, frame->data[1], frame->data[2]);
 
     if (avctx->codec_tag == AV_RL32("yuv2") &&
         avctx->pix_fmt   == AV_PIX_FMT_YUYV422) {
         int x, y;
-        uint8_t *line = picture->data[0];
+        uint8_t *line = frame->data[0];
         for (y = 0; y < avctx->height; y++) {
             for (x = 0; x < avctx->width; x++)
                 line[2 * x + 1] ^= 0x80;
-            line += picture->linesize[0];
+            line += frame->linesize[0];
         }
     }
 
@@ -254,11 +259,11 @@ static av_cold int raw_close_decoder(AVCodecContext *avctx)
 
 AVCodec ff_rawvideo_decoder = {
     .name           = "rawvideo",
+    .long_name      = NULL_IF_CONFIG_SMALL("raw video"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_RAWVIDEO,
     .priv_data_size = sizeof(RawVideoContext),
     .init           = raw_init_decoder,
     .close          = raw_close_decoder,
     .decode         = raw_decode,
-    .long_name      = NULL_IF_CONFIG_SMALL("raw video"),
 };