]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/zmbv.c
lavc: add Intel libmfx-based MPEG2 decoder.
[ffmpeg] / libavcodec / zmbv.c
index 0b38926bc81b79063e4391082cad9dba875b82db..f49cbdb014f72c438260069a8a851a9e80afe6f8 100644 (file)
@@ -493,14 +493,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
         c->by   = (c->height + c->bh - 1) / c->bh;
     }
 
-    if (c->decode_intra == NULL) {
+    if (!c->decode_intra) {
         av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
         return AVERROR_INVALIDDATA;
     }
 
     if (c->comp == 0) { //Uncompressed data
+        if (c->decomp_size < len) {
+            av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
+            return AVERROR_INVALIDDATA;
+        }
         memcpy(c->decomp_buf, buf, len);
-        c->decomp_size = 1;
     } else { // ZLIB-compressed data
         c->zstream.total_in = c->zstream.total_out = 0;
         c->zstream.next_in = buf;
@@ -618,7 +621,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     /* Allocate decompression buffer */
     if (c->decomp_size) {
-        if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) {
+        if (!(c->decomp_buf = av_malloc(c->decomp_size))) {
             av_log(avctx, AV_LOG_ERROR,
                    "Can't allocate decompression buffer.\n");
             return AVERROR(ENOMEM);
@@ -652,6 +655,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
 
 AVCodec ff_zmbv_decoder = {
     .name           = "zmbv",
+    .long_name      = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_ZMBV,
     .priv_data_size = sizeof(ZmbvContext),
@@ -659,5 +663,4 @@ AVCodec ff_zmbv_decoder = {
     .close          = decode_end,
     .decode         = decode_frame,
     .capabilities   = CODEC_CAP_DR1,
-    .long_name      = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
 };