[FFmpeg-cvslog] r25912 - in trunk/libavcodec: flac.c flac.h flacdec.c

jbr subversion
Tue Dec 7 15:00:38 CET 2010


Author: jbr
Date: Tue Dec  7 15:00:38 2010
New Revision: 25912

Log:
Add log_level_offset parameter to ff_flac_decode_frame_header(). It will be used 
to optionally silence the error messages.
Patch by Michael Chinen [mchinen at gmail]

Modified:
   trunk/libavcodec/flac.c
   trunk/libavcodec/flac.h
   trunk/libavcodec/flacdec.c

Modified: trunk/libavcodec/flac.c
==============================================================================
--- trunk/libavcodec/flac.c	Tue Dec  7 14:50:13 2010	(r25911)
+++ trunk/libavcodec/flac.c	Tue Dec  7 15:00:38 2010	(r25912)
@@ -33,13 +33,13 @@ static int64_t get_utf8(GetBitContext *g
 }
 
 int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
-                                FLACFrameInfo *fi)
+                                FLACFrameInfo *fi, int log_level_offset)
 {
     int bs_code, sr_code, bps_code;
 
     /* frame sync code */
     if ((get_bits(gb, 15) & 0x7FFF) != 0x7FFC) {
-        av_log(avctx, AV_LOG_ERROR, "invalid sync code\n");
+        av_log(avctx, AV_LOG_ERROR + log_level_offset, "invalid sync code\n");
         return -1;
     }
 
@@ -58,14 +58,14 @@ int ff_flac_decode_frame_header(AVCodecC
     } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
         fi->channels = 2;
     } else {
-        av_log(avctx, AV_LOG_ERROR, "invalid channel mode: %d\n", fi->ch_mode);
+        av_log(avctx, AV_LOG_ERROR + log_level_offset, "invalid channel mode: %d\n", fi->ch_mode);
         return -1;
     }
 
     /* bits per sample */
     bps_code = get_bits(gb, 3);
     if (bps_code == 3 || bps_code == 7) {
-        av_log(avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
+        av_log(avctx, AV_LOG_ERROR + log_level_offset, "invalid sample size code (%d)\n",
                bps_code);
         return -1;
     }
@@ -73,20 +73,20 @@ int ff_flac_decode_frame_header(AVCodecC
 
     /* reserved bit */
     if (get_bits1(gb)) {
-        av_log(avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
+        av_log(avctx, AV_LOG_ERROR + log_level_offset, "broken stream, invalid padding\n");
         return -1;
     }
 
     /* sample or frame count */
     fi->frame_or_sample_num = get_utf8(gb);
     if (fi->frame_or_sample_num < 0) {
-        av_log(avctx, AV_LOG_ERROR, "sample/frame number invalid; utf8 fscked\n");
+        av_log(avctx, AV_LOG_ERROR + log_level_offset, "sample/frame number invalid; utf8 fscked\n");
         return -1;
     }
 
     /* blocksize */
     if (bs_code == 0) {
-        av_log(avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n");
+        av_log(avctx, AV_LOG_ERROR + log_level_offset, "reserved blocksize code: 0\n");
         return -1;
     } else if (bs_code == 6) {
         fi->blocksize = get_bits(gb, 8) + 1;
@@ -106,7 +106,7 @@ int ff_flac_decode_frame_header(AVCodecC
     } else if (sr_code == 14) {
         fi->samplerate = get_bits(gb, 16) * 10;
     } else {
-        av_log(avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
+        av_log(avctx, AV_LOG_ERROR + log_level_offset, "illegal sample rate code %d\n",
                sr_code);
         return -1;
     }
@@ -115,7 +115,7 @@ int ff_flac_decode_frame_header(AVCodecC
     skip_bits(gb, 8);
     if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer,
                get_bits_count(gb)/8)) {
-        av_log(avctx, AV_LOG_ERROR, "header crc mismatch\n");
+        av_log(avctx, AV_LOG_ERROR + log_level_offset, "header crc mismatch\n");
         return -1;
     }
 

Modified: trunk/libavcodec/flac.h
==============================================================================
--- trunk/libavcodec/flac.h	Tue Dec  7 14:50:13 2010	(r25911)
+++ trunk/libavcodec/flac.h	Tue Dec  7 15:00:38 2010	(r25912)
@@ -131,8 +131,9 @@ int ff_flac_get_max_frame_size(int block
  * @param      avctx AVCodecContext to use as av_log() context
  * @param      gb    GetBitContext from which to read frame header
  * @param[out] fi    frame information
+ * @param      log_level_offset  log level offset. can be used to silence error messages.
  * @return non-zero on error, 0 if ok
  */
 int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
-                                FLACFrameInfo *fi);
+                                FLACFrameInfo *fi, int log_level_offset);
 #endif /* AVCODEC_FLAC_H */

Modified: trunk/libavcodec/flacdec.c
==============================================================================
--- trunk/libavcodec/flacdec.c	Tue Dec  7 14:50:13 2010	(r25911)
+++ trunk/libavcodec/flacdec.c	Tue Dec  7 15:00:38 2010	(r25912)
@@ -476,7 +476,7 @@ static int decode_frame(FLACContext *s)
     GetBitContext *gb = &s->gb;
     FLACFrameInfo fi;
 
-    if (ff_flac_decode_frame_header(s->avctx, gb, &fi)) {
+    if (ff_flac_decode_frame_header(s->avctx, gb, &fi, 0)) {
         av_log(s->avctx, AV_LOG_ERROR, "invalid frame header\n");
         return -1;
     }



More information about the ffmpeg-cvslog mailing list