[SCM] libav/experimental: CODEC_CAP_SMALL_LAST_FRAME patch by Justin Ruggles jruggle earthlink net

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 15:48:15 UTC 2013


The following commit has been merged in the experimental branch:
commit cef7cc72321670a37b758cb9a3382ddf609876aa
Author: Justin Ruggles <jruggle at earthlink.net>
Date:   Sat Jun 24 09:25:21 2006 +0000

    CODEC_CAP_SMALL_LAST_FRAME patch by Justin Ruggles jruggle earthlink net
    
    Originally committed as revision 5512 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/ffmpeg.c b/ffmpeg.c
index 3834ff6..8883191 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1358,12 +1358,29 @@ static int output_packet(AVInputStream *ist, int ist_index,
                 if (ost->encoding_needed) {
                     for(;;) {
                         AVPacket pkt;
+                        int fifo_bytes;
                         av_init_packet(&pkt);
                         pkt.stream_index= ost->index;
 
                         switch(ost->st->codec->codec_type) {
                         case CODEC_TYPE_AUDIO:
-                            ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL);
+                            fifo_bytes = fifo_size(&ost->fifo, NULL);
+                            ret = 0;
+                            /* encode any samples remaining in fifo */
+                            if(fifo_bytes > 0 && enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
+                                int fs_tmp = enc->frame_size;
+                                enc->frame_size = fifo_bytes / (2 * enc->channels);
+                                if(fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes,
+                                        &ost->fifo.rptr) == 0) {
+                                    ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples);
+                                }
+                                enc->frame_size = fs_tmp;
+                                if(ret <= 0) {
+                                    ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL);
+                                }
+                            } else {
+                                ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL);
+                            }
                             audio_size += ret;
                             pkt.flags |= PKT_FLAG_KEY;
                             break;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a879419..95a3dd0 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -365,6 +365,11 @@ extern int motion_estimation_method;
  * if this is not set, the codec is guranteed to never be feeded with NULL data
  */
 #define CODEC_CAP_DELAY           0x0020
+/**
+ * Codec can be fed a final frame with a smaller size.
+ * This can be used to prevent truncation of the last audio samples.
+ */
+#define CODEC_CAP_SMALL_LAST_FRAME 0x0040
 
 //the following defines may change, don't expect compatibility if you use them
 #define MB_TYPE_INTRA4x4   0x0001

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list