]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/imc.c
mpeg12: do not fail on zero dimensions in the sequence header.
[ffmpeg] / libavcodec / imc.c
index 6dac4302848fac6a9d84b2ca48b930295bc0563b..2749099d22a067dd65d3822b665a4be4528cb7ee 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
+#include "libavutil/internal.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "dsputil.h"
@@ -79,8 +80,6 @@ typedef struct IMCChannel {
 } IMCChannel;
 
 typedef struct {
-    AVFrame frame;
-
     IMCChannel chctx[2];
 
     /** MDCT tables */
@@ -182,7 +181,7 @@ static av_cold int imc_decode_init(AVCodecContext *avctx)
         avctx->channels = 1;
 
     if (avctx->channels > 2) {
-        av_log_ask_for_sample(avctx, "Number of channels is not supported\n");
+        avpriv_request_sample(avctx, "Number of channels > 2");
         return AVERROR_PATCHWELCOME;
     }
 
@@ -251,9 +250,6 @@ static av_cold int imc_decode_init(AVCodecContext *avctx)
     avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO
                                                  : AV_CH_LAYOUT_STEREO;
 
-    avcodec_get_frame_defaults(&q->frame);
-    avctx->coded_frame = &q->frame;
-
     return 0;
 }
 
@@ -782,8 +778,7 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
     stream_format_code = get_bits(&q->gb, 3);
 
     if (stream_format_code & 1) {
-        av_log_ask_for_sample(avctx, "Stream format %X is not supported\n",
-                              stream_format_code);
+        avpriv_request_sample(avctx, "Stream format %X", stream_format_code);
         return AVERROR_PATCHWELCOME;
     }
 
@@ -928,6 +923,7 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
 static int imc_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)
 {
+    AVFrame *frame     = data;
     const uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;
     int ret, i;
@@ -942,14 +938,14 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data,
     }
 
     /* get output buffer */
-    q->frame.nb_samples = COEFFS;
-    if ((ret = ff_get_buffer(avctx, &q->frame)) < 0) {
+    frame->nb_samples = COEFFS;
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return ret;
     }
 
     for (i = 0; i < avctx->channels; i++) {
-        q->out_samples = (float *)q->frame.extended_data[i];
+        q->out_samples = (float *)frame->extended_data[i];
 
         q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2);
 
@@ -962,12 +958,11 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data,
     }
 
     if (avctx->channels == 2) {
-        q->fdsp.butterflies_float((float *)q->frame.extended_data[0],
-                                  (float *)q->frame.extended_data[1], COEFFS);
+        q->fdsp.butterflies_float((float *)frame->extended_data[0],
+                                  (float *)frame->extended_data[1], COEFFS);
     }
 
-    *got_frame_ptr   = 1;
-    *(AVFrame *)data = q->frame;
+    *got_frame_ptr = 1;
 
     return IMC_BLOCK_SIZE * avctx->channels;
 }