[vlc-devel] commit: Fixed non compatible avcodec flac extradata. (Laurent Aimar )

git version control git at videolan.org
Fri May 1 01:06:41 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Fri May  1 01:04:03 2009 +0200| [a000d2188fcaedd136a443a1fe946d291c1bf492] | committer: Laurent Aimar 

Fixed non compatible avcodec flac extradata.

avcodec will now output extradata using the same format than flac encoder.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a000d2188fcaedd136a443a1fe946d291c1bf492
---

 modules/codec/avcodec/encoder.c |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 3b1a17f..092090d 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -693,13 +693,39 @@ int OpenEncoder( vlc_object_t *p_this )
         }
     }
 
-    p_enc->fmt_out.i_extra = p_context->extradata_size;
-    if( p_enc->fmt_out.i_extra )
+    if( i_codec_id == CODEC_ID_FLAC )
     {
+        p_enc->fmt_out.i_extra = 4 + 1 + 3 + p_context->extradata_size;
         p_enc->fmt_out.p_extra = malloc( p_enc->fmt_out.i_extra );
-        memcpy( p_enc->fmt_out.p_extra, p_context->extradata,
-                p_enc->fmt_out.i_extra );
+        if( p_enc->fmt_out.p_extra )
+        {
+            uint8_t *p = p_enc->fmt_out.p_extra;
+            p[0] = 0x66;
+            p[1] = 0x4C;
+            p[2] = 0x61;
+            p[3] = 0x43;
+            p[4] = 0x00;
+            p[5] = ( p_context->extradata_size >> 16 ) & 0xff;
+            p[6] = ( p_context->extradata_size >>  8 ) & 0xff;
+            p[7] = ( p_context->extradata_size       ) & 0xff;
+            memcpy( &p[8], p_context->extradata, p_context->extradata_size );
+        }
+        else
+        {
+            p_enc->fmt_out.i_extra = 0;
+        }
     }
+    else
+    {
+        p_enc->fmt_out.i_extra = p_context->extradata_size;
+        if( p_enc->fmt_out.i_extra )
+        {
+            p_enc->fmt_out.p_extra = malloc( p_enc->fmt_out.i_extra );
+            memcpy( p_enc->fmt_out.p_extra, p_context->extradata,
+                    p_enc->fmt_out.i_extra );
+        }
+    }
+
     p_context->flags &= ~CODEC_FLAG_GLOBAL_HEADER;
 
     if( p_enc->fmt_in.i_cat == AUDIO_ES )




More information about the vlc-devel mailing list