]> git.sesse.net Git - ffmpeg/commitdiff
ffmpeg: move subframe warning to libavcodec
authorwm4 <nfxjfg@googlemail.com>
Sat, 1 Oct 2016 15:22:02 +0000 (17:22 +0200)
committerwm4 <nfxjfg@googlemail.com>
Sat, 1 Oct 2016 15:22:02 +0000 (17:22 +0200)
With the new decode API, doing this in ffmpeg.c is impractical. There
was resistance against removing the warning, so put it into libavcodec.

Not bothering with reducing the warning to verbose log level for
subsequent wanrings. The warning should be rare, and only happen when
developing new codecs for the old API.

Includes a change suggested by Michael Niedermayer.

ffmpeg.c
ffmpeg.h
libavcodec/internal.h
libavcodec/utils.c

index 9a8e65a1e3c2033936cdd9579524a92667cb1160..ff5f98b36c22d0f5cb4c974f403a4c090a2d85fa 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2357,13 +2357,6 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
         ist->pts = ist->next_pts;
         ist->dts = ist->next_dts;
 
-        if (avpkt.size && avpkt.size != pkt->size &&
-            !(ist->dec->capabilities & AV_CODEC_CAP_SUBFRAMES)) {
-            av_log(NULL, ist->showed_multi_packet_warning ? AV_LOG_VERBOSE : AV_LOG_WARNING,
-                   "Multiple frames in a packet from stream %d\n", pkt->stream_index);
-            ist->showed_multi_packet_warning = 1;
-        }
-
         switch (ist->dec_ctx->codec_type) {
         case AVMEDIA_TYPE_AUDIO:
             ret = decode_audio    (ist, &avpkt, &got_output);
index 0d01d2bab7807212d129e7067269428356dcaecb..3ba62a1840f90bc9ac2c5c9f20021f59097f2129 100644 (file)
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -287,7 +287,6 @@ typedef struct InputStream {
 
     double ts_scale;
     int saw_first_ts;
-    int showed_multi_packet_warning;
     AVDictionary *decoder_opts;
     AVRational framerate;               /* framerate forced with -r */
     int top_field_first;
index 000fe263cc2911dbfbb95a814822215c8799c8f1..35b9630b52b7f7f3d4ed963633af6bc1f506efa4 100644 (file)
@@ -173,6 +173,7 @@ typedef struct AVCodecInternal {
     int buffer_pkt_valid; // encoding: packet without data can be valid
     AVFrame *buffer_frame;
     int draining_done;
+    int showed_multi_packet_warning;
 } AVCodecInternal;
 
 struct AVCodecDefault {
index cf8530060545158ea2228d391a334911e7041015..ef3da651444156ea1e510d621671d4742886aa7a 100644 (file)
@@ -2461,6 +2461,12 @@ fail:
 
     av_assert0(ret <= avpkt->size);
 
+    if (!avci->showed_multi_packet_warning &&
+        ret >= 0 && ret != avpkt->size && !(avctx->codec->capabilities & AV_CODEC_CAP_SUBFRAMES)) {
+            av_log(avctx, AV_LOG_WARNING, "Multiple frames in a packet.\n");
+        avci->showed_multi_packet_warning = 1;
+    }
+
     return ret;
 }