Browse Source

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  fate: split off DPCM codec FATE tests into their own file
  fate: split off PCM codec FATE tests into their own file
  libvorbis: K&R reformatting cosmetics
  libmp3lame: K&R formatting cosmetics
  fate: Add a video test for xxan decoder
  mpegvideo_enc: K&R cosmetics (line 1000-2000).
  avconv: K&R cosmetics
  qt-faststart: Fix up indentation
  indeo4: remove two unused variables
  doxygen: cleanup style to support older doxy
  fate: add more tests for VC-1 decoder
  applehttpproto: Apply the same reload interval changes as for the demuxer
  applehttp: Use half the target duration as interval if the playlist didn't update
  applehttp: Use the last segment duration as reload interval
  lagarith: add decode support for arith rgb24 mode

Conflicts:
	avconv.c
	libavcodec/libmp3lame.c
	libavcodec/mpegvideo_enc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Michael Niedermayer 13 years ago
parent
commit
00c0465dbc
10 changed files with 1181 additions and 1034 deletions
  1. 228 223
      avconv.c
  2. 21 54
      doc/doxy/doxy_stylesheet.css
  3. 218 215
      ffmpeg.c
  4. 7 4
      libavcodec/indeo4.c
  5. 72 67
      libavcodec/libmp3lame.c
  6. 79 73
      libavcodec/libvorbis.c
  7. 527 390
      libavcodec/mpegvideo_enc.c
  8. 15 6
      libavformat/applehttp.c
  9. 12 2
      libavformat/applehttpproto.c
  10. 2 0
      tests/Makefile

File diff suppressed because it is too large
+ 228 - 223
avconv.c


+ 21 - 54
doc/doxy/doxy_stylesheet.css

@@ -235,6 +235,8 @@ div.center img {
 #footer {
     margin: -10px 1em 0;
     padding-top: 20px;
+    text-align: center;
+    font-size: small;
 }
 
 address.footer {
@@ -962,7 +964,7 @@ dl.citelist dd {
 }
 
 .tabs3 .tablist a {
-    padding: 0 10px;
+    padding-left: 10px;
 }
 
 
@@ -981,19 +983,6 @@ h1 a, h2 a, h3 a {
     color: inherit;
 }
 
-#banner, #top {
-    background-color: #BBC9D8;
-    border-bottom: 1px solid #7A96B3;
-    border-top: 1px solid #7A96B3;
-    position: relative;
-    text-align: center;
-}
-
-#banner img, #top img {
-    padding-bottom: 1px;
-    padding-top: 5px;
-}
-
 #body {
     margin: 0 1em;
 }
@@ -1041,12 +1030,12 @@ img {
     border: 0;
 }
 
-#navrow1 {
+.tabs {
     margin-top: 12px;
     border-top: 1px solid #5C665C;
 }
 
-#navrow1, #navrow2, #navrow3, #navrow4 {
+.tabs, .tabs2, .tabs3, .tabs4 {
     background-color: #738073;
     border-bottom: 1px solid #5C665C;
     border-left: 1px solid #5C665C;
@@ -1055,24 +1044,36 @@ img {
     text-align: center;
 }
 
-#navrow1 a, #navrow2 a, #navrow3 a, #navrow4 a {
+.tabs a,
+.tabs2 a,
+.tabs3 a,
+.tabs4 a {
     color: white;
     padding: 0.3em;
     text-decoration: none;
 }
 
 
-#navrow1 ul, #navrow2 ul, #navrow3 ul, #navrow4 ul {
+.tabs ul,
+.tabs2 ul,
+.tabs3 ul,
+.tabs4 ul {
     padding: 0;
 }
 
-#navrow1 li.current a, #navrow2 li.current a, #navrow3 li.current a, #navrow4 li.current a {
+.tabs li.current a,
+.tabs2 li.current a,
+.tabs3 li.current a,
+.tabs4 li.current a {
     background-color: #414141;
     color: white;
     text-decoration: none;
 }
 
-#navrow1 a:hover, #navrow2 a:hover, #navrow3 a:hover, #navrow4 a:hover {
+.tabs a:hover,
+.tabs2 a:hover,
+.tabs3 a:hover,
+.tabs4 a:hover {
     background-color: #313131 !important;
     color: white;
     text-decoration: none;
@@ -1094,37 +1095,3 @@ pre {
 #proj_desc {
     font-size: 1.2em;
 }
-
-#repos {
-    margin-left: 1em;
-    margin-right: 1em;
-    border-collapse: collapse;
-    border: solid 1px #6A996A;
-}
-
-#repos th {
-    background-color: #7BB37B;
-    border: solid 1px #6A996A;
-}
-
-#repos td {
-    padding: 0.2em;
-    border: solid 1px #6A996A;
-}
-
-#distro_status {
-    margin-left: 1em;
-    margin-right: 1em;
-    border-collapse: collapse;
-    border: solid 1px #6A996A;
-}
-
-#distro_status th {
-    background-color: #7BB37B;
-    border: solid 1px #6A996A;
-}
-
-#distro_status td {
-    padding: 0.2em;
-    border: solid 1px #6A996A;
-}

File diff suppressed because it is too large
+ 218 - 215
ffmpeg.c


+ 7 - 4
libavcodec/indeo4.c

@@ -160,7 +160,7 @@ static inline int scale_tile_size(int def_size, int size_factor)
  */
 static int decode_pic_hdr(IVI4DecContext *ctx, AVCodecContext *avctx)
 {
-    int             pic_size_indx, val, i, p;
+    int             pic_size_indx, i, p;
     IVIPicConfig    pic_conf;
 
     if (get_bits(&ctx->gb, 18) != 0x3FFF8) {
@@ -301,7 +301,7 @@ static int decode_pic_hdr(IVI4DecContext *ctx, AVCodecContext *avctx)
     /* skip picture header extension if any */
     while (get_bits1(&ctx->gb)) {
         av_dlog(avctx, "Pic hdr extension encountered!\n");
-        val = get_bits(&ctx->gb, 8);
+        skip_bits(&ctx->gb, 8);
     }
 
     if (get_bits1(&ctx->gb)) {
@@ -325,7 +325,7 @@ static int decode_pic_hdr(IVI4DecContext *ctx, AVCodecContext *avctx)
 static int decode_band_hdr(IVI4DecContext *ctx, IVIBandDesc *band,
                            AVCodecContext *avctx)
 {
-    int plane, band_num, hdr_size, indx, transform_id, scan_indx;
+    int plane, band_num, indx, transform_id, scan_indx;
     int i;
 
     plane    = get_bits(&ctx->gb, 2);
@@ -337,7 +337,10 @@ static int decode_band_hdr(IVI4DecContext *ctx, IVIBandDesc *band,
 
     band->is_empty = get_bits1(&ctx->gb);
     if (!band->is_empty) {
-        hdr_size = get_bits1(&ctx->gb) ? get_bits(&ctx->gb, 16) : 4;
+        /* skip header size
+         * If header size is not given, header size is 4 bytes. */
+        if (get_bits1(&ctx->gb))
+            skip_bits(&ctx->gb, 16);
 
         band->is_halfpel = get_bits(&ctx->gb, 2);
         if (band->is_halfpel >= 2) {

+ 72 - 67
libavcodec/libmp3lame.c

@@ -31,7 +31,7 @@
 #include "mpegaudio.h"
 #include <lame/lame.h>
 
-#define BUFFER_SIZE (7200 + 2*MPA_FRAME_SIZE + MPA_FRAME_SIZE/4)
+#define BUFFER_SIZE (7200 + 2 * MPA_FRAME_SIZE + MPA_FRAME_SIZE / 4)
 typedef struct Mp3AudioContext {
     AVClass *class;
     lame_global_flags *gfp;
@@ -62,17 +62,17 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
     lame_set_in_samplerate(s->gfp, avctx->sample_rate);
     lame_set_out_samplerate(s->gfp, avctx->sample_rate);
     lame_set_num_channels(s->gfp, avctx->channels);
-    if(avctx->compression_level == FF_COMPRESSION_DEFAULT) {
+    if (avctx->compression_level == FF_COMPRESSION_DEFAULT) {
         lame_set_quality(s->gfp, 5);
     } else {
         lame_set_quality(s->gfp, avctx->compression_level);
     }
     lame_set_mode(s->gfp, s->stereo ? JOINT_STEREO : MONO);
-    lame_set_brate(s->gfp, avctx->bit_rate/1000);
-    if(avctx->flags & CODEC_FLAG_QSCALE) {
+    lame_set_brate(s->gfp, avctx->bit_rate / 1000);
+    if (avctx->flags & CODEC_FLAG_QSCALE) {
         lame_set_brate(s->gfp, 0);
         lame_set_VBR(s->gfp, vbr_default);
-        lame_set_VBR_quality(s->gfp, avctx->global_quality/(float)FF_QP2LAMBDA);
+        lame_set_VBR_quality(s->gfp, avctx->global_quality / (float)FF_QP2LAMBDA);
     }
     lame_set_bWriteVbrTag(s->gfp,0);
 #if FF_API_LAME_GLOBAL_OPTS
@@ -82,14 +82,14 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
     if (lame_init_params(s->gfp) < 0)
         goto err_close;
 
-    avctx->frame_size = lame_get_framesize(s->gfp);
+    avctx->frame_size             = lame_get_framesize(s->gfp);
 
     if(!(avctx->coded_frame= avcodec_alloc_frame())) {
         lame_close(s->gfp);
 
         return AVERROR(ENOMEM);
     }
-    avctx->coded_frame->key_frame= 1;
+    avctx->coded_frame->key_frame = 1;
 
     if(AV_SAMPLE_FMT_S32 == avctx->sample_fmt && s->stereo) {
         int nelem = 2 * avctx->frame_size;
@@ -117,60 +117,62 @@ static const int sSampleRates[] = {
 };
 
 static const int sBitRates[2][3][15] = {
-    {   {  0, 32, 64, 96,128,160,192,224,256,288,320,352,384,416,448},
-        {  0, 32, 48, 56, 64, 80, 96,112,128,160,192,224,256,320,384},
-        {  0, 32, 40, 48, 56, 64, 80, 96,112,128,160,192,224,256,320}
+    {
+        { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
+        { 0, 32, 48, 56, 64,  80,  96,  112, 128, 160, 192, 224, 256, 320, 384 },
+        { 0, 32, 40, 48, 56,  64,  80,  96,  112, 128, 160, 192, 224, 256, 320 }
     },
-    {   {  0, 32, 48, 56, 64, 80, 96,112,128,144,160,176,192,224,256},
-        {  0,  8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160},
-        {  0,  8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160}
+    {
+        { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 },
+        { 0,  8, 16, 24, 32, 40, 48,  56,  64,  80,  96, 112, 128, 144, 160 },
+        { 0,  8, 16, 24, 32, 40, 48,  56,  64,  80,  96, 112, 128, 144, 160 }
     },
 };
 
-static const int sSamplesPerFrame[2][3] =
-{
-    {  384,     1152,    1152 },
-    {  384,     1152,     576 }
+static const int sSamplesPerFrame[2][3] = {
+    { 384, 1152, 1152 },
+    { 384, 1152,  576 }
 };
 
-static const int sBitsPerSlot[3] = {
-    32,
-    8,
-    8
-};
+static const int sBitsPerSlot[3] = { 32, 8, 8 };
 
 static int mp3len(void *data, int *samplesPerFrame, int *sampleRate)
 {
-    uint32_t header = AV_RB32(data);
-    int layerID = 3 - ((header >> 17) & 0x03);
-    int bitRateID = ((header >> 12) & 0x0f);
+    uint32_t header  = AV_RB32(data);
+    int layerID      = 3 - ((header >> 17) & 0x03);
+    int bitRateID    = ((header >> 12) & 0x0f);
     int sampleRateID = ((header >> 10) & 0x03);
-    int bitsPerSlot = sBitsPerSlot[layerID];
-    int isPadded = ((header >> 9) & 0x01);
-    static int const mode_tab[4]= {2,3,1,0};
-    int mode= mode_tab[(header >> 19) & 0x03];
-    int mpeg_id= mode>0;
+    int bitsPerSlot  = sBitsPerSlot[layerID];
+    int isPadded     = ((header >> 9) & 0x01);
+    static int const mode_tab[4] = { 2, 3, 1, 0 };
+    int mode    = mode_tab[(header >> 19) & 0x03];
+    int mpeg_id = mode > 0;
     int temp0, temp1, bitRate;
 
-    if ( (( header >> 21 ) & 0x7ff) != 0x7ff || mode == 3 || layerID==3 || sampleRateID==3) {
+    if (((header >> 21) & 0x7ff) != 0x7ff || mode == 3 || layerID == 3 ||
+        sampleRateID == 3) {
         return -1;
     }
 
-    if(!samplesPerFrame) samplesPerFrame= &temp0;
-    if(!sampleRate     ) sampleRate     = &temp1;
+    if (!samplesPerFrame)
+        samplesPerFrame = &temp0;
+    if (!sampleRate)
+        sampleRate      = &temp1;
 
-//    *isMono = ((header >>  6) & 0x03) == 0x03;
+    //*isMono = ((header >>  6) & 0x03) == 0x03;
 
-    *sampleRate = sSampleRates[sampleRateID]>>mode;
-    bitRate = sBitRates[mpeg_id][layerID][bitRateID] * 1000;
+    *sampleRate      = sSampleRates[sampleRateID] >> mode;
+    bitRate          = sBitRates[mpeg_id][layerID][bitRateID] * 1000;
     *samplesPerFrame = sSamplesPerFrame[mpeg_id][layerID];
-//av_log(NULL, AV_LOG_DEBUG, "sr:%d br:%d spf:%d l:%d m:%d\n", *sampleRate, bitRate, *samplesPerFrame, layerID, mode);
+    //av_log(NULL, AV_LOG_DEBUG,
+    //       "sr:%d br:%d spf:%d l:%d m:%d\n",
+    //       *sampleRate, bitRate, *samplesPerFrame, layerID, mode);
 
     return *samplesPerFrame * bitRate / (bitsPerSlot * *sampleRate) + isPadded;
 }
 
-static int MP3lame_encode_frame(AVCodecContext *avctx,
-                                unsigned char *frame, int buf_size, void *data)
+static int MP3lame_encode_frame(AVCodecContext *avctx, unsigned char *frame,
+                                int buf_size, void *data)
 {
     Mp3AudioContext *s = avctx->priv_data;
     int len;
@@ -178,7 +180,7 @@ static int MP3lame_encode_frame(AVCodecContext *avctx,
 
     /* lame 3.91 dies on '1-channel interleaved' data */
 
-    if(!data){
+    if (!data){
         lame_result= lame_encode_flush(
                 s->gfp,
                 s->buffer + s->buffer_index,
@@ -237,32 +239,35 @@ static int MP3lame_encode_frame(AVCodecContext *avctx,
         }
     }
 
-    if(lame_result < 0){
-        if(lame_result==-1) {
+    if (lame_result < 0) {
+        if (lame_result == -1) {
             /* output buffer too small */
-            av_log(avctx, AV_LOG_ERROR, "lame: output buffer too small (buffer index: %d, free bytes: %d)\n", s->buffer_index, BUFFER_SIZE - s->buffer_index);
+            av_log(avctx, AV_LOG_ERROR,
+                   "lame: output buffer too small (buffer index: %d, free bytes: %d)\n",
+                   s->buffer_index, BUFFER_SIZE - s->buffer_index);
         }
         return -1;
     }
 
     s->buffer_index += lame_result;
 
-    if(s->buffer_index<4)
+    if (s->buffer_index < 4)
         return 0;
 
-    len= mp3len(s->buffer, NULL, NULL);
-//av_log(avctx, AV_LOG_DEBUG, "in:%d packet-len:%d index:%d\n", avctx->frame_size, len, s->buffer_index);
-    if(len <= s->buffer_index){
+    len = mp3len(s->buffer, NULL, NULL);
+    //av_log(avctx, AV_LOG_DEBUG, "in:%d packet-len:%d index:%d\n",
+    //       avctx->frame_size, len, s->buffer_index);
+    if (len <= s->buffer_index) {
         memcpy(frame, s->buffer, len);
         s->buffer_index -= len;
 
-        memmove(s->buffer, s->buffer+len, s->buffer_index);
-            //FIXME fix the audio codec API, so we do not need the memcpy()
-/*for(i=0; i<len; i++){
-    av_log(avctx, AV_LOG_DEBUG, "%2X ", frame[i]);
-}*/
+        memmove(s->buffer, s->buffer + len, s->buffer_index);
+        // FIXME fix the audio codec API, so we do not need the memcpy()
+        /*for(i=0; i<len; i++) {
+            av_log(avctx, AV_LOG_DEBUG, "%2X ", frame[i]);
+        }*/
         return len;
-    }else
+    } else
         return 0;
 }
 
@@ -280,7 +285,7 @@ static av_cold int MP3lame_encode_close(AVCodecContext *avctx)
 #define OFFSET(x) offsetof(Mp3AudioContext, x)
 #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
-    { "reservoir",      "Use bit reservoir.",   OFFSET(reservoir),  AV_OPT_TYPE_INT, { 1 }, 0, 1, AE },
+    { "reservoir", "Use bit reservoir.", OFFSET(reservoir), AV_OPT_TYPE_INT, { 1 }, 0, 1, AE },
     { NULL },
 };
 
@@ -292,20 +297,20 @@ static const AVClass libmp3lame_class = {
 };
 
 AVCodec ff_libmp3lame_encoder = {
-    .name           = "libmp3lame",
-    .type           = AVMEDIA_TYPE_AUDIO,
-    .id             = CODEC_ID_MP3,
-    .priv_data_size = sizeof(Mp3AudioContext),
-    .init           = MP3lame_encode_init,
-    .encode         = MP3lame_encode_frame,
-    .close          = MP3lame_encode_close,
-    .capabilities= CODEC_CAP_DELAY,
-    .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,
+    .name                  = "libmp3lame",
+    .type                  = AVMEDIA_TYPE_AUDIO,
+    .id                    = CODEC_ID_MP3,
+    .priv_data_size        = sizeof(Mp3AudioContext),
+    .init                  = MP3lame_encode_init,
+    .encode                = MP3lame_encode_frame,
+    .close                 = MP3lame_encode_close,
+    .capabilities          = CODEC_CAP_DELAY,
+    .sample_fmts           = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
 #if 2147483647 == INT_MAX
     AV_SAMPLE_FMT_S32,
 #endif
-    AV_SAMPLE_FMT_NONE},
-    .supported_samplerates= sSampleRates,
-    .long_name= NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"),
-    .priv_class     = &libmp3lame_class,
+                                                             AV_SAMPLE_FMT_NONE },
+    .supported_samplerates = sSampleRates,
+    .long_name             = NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"),
+    .priv_class            = &libmp3lame_class,
 };

+ 79 - 73
libavcodec/libvorbis.c

@@ -37,63 +37,65 @@
 
 #define OGGVORBIS_FRAME_SIZE 64
 
-#define BUFFER_SIZE (1024*64)
+#define BUFFER_SIZE (1024 * 64)
 
 typedef struct OggVorbisContext {
     AVClass *av_class;
-    vorbis_info vi ;
-    vorbis_dsp_state vd ;
-    vorbis_block vb ;
+    vorbis_info vi;
+    vorbis_dsp_state vd;
+    vorbis_block vb;
     uint8_t buffer[BUFFER_SIZE];
     int buffer_index;
     int eof;
 
     /* decoder */
-    vorbis_comment vc ;
+    vorbis_comment vc;
     ogg_packet op;
 
     double iblock;
-} OggVorbisContext ;
+} OggVorbisContext;
 
-static const AVOption options[]={
-{"iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, iblock), AV_OPT_TYPE_DOUBLE, {.dbl = 0}, -15, 0, AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_ENCODING_PARAM},
-{NULL}
+static const AVOption options[] = {
+    { "iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, iblock), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -15, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
+    { NULL }
 };
 static const AVClass class = { "libvorbis", av_default_item_name, options, LIBAVUTIL_VERSION_INT };
 
-static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) {
-    OggVorbisContext *context = avccontext->priv_data ;
+static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext)
+{
+    OggVorbisContext *context = avccontext->priv_data;
     double cfreq;
 
-    if(avccontext->flags & CODEC_FLAG_QSCALE) {
+    if (avccontext->flags & CODEC_FLAG_QSCALE) {
         /* variable bitrate */
-        if(vorbis_encode_setup_vbr(vi, avccontext->channels,
-                avccontext->sample_rate,
-                avccontext->global_quality / (float)FF_QP2LAMBDA / 10.0))
+        if (vorbis_encode_setup_vbr(vi, avccontext->channels,
+                                    avccontext->sample_rate,
+                                    avccontext->global_quality / (float)FF_QP2LAMBDA / 10.0))
             return -1;
     } else {
         int minrate = avccontext->rc_min_rate > 0 ? avccontext->rc_min_rate : -1;
         int maxrate = avccontext->rc_min_rate > 0 ? avccontext->rc_max_rate : -1;
 
         /* constant bitrate */
-        if(vorbis_encode_setup_managed(vi, avccontext->channels,
-                avccontext->sample_rate, minrate, avccontext->bit_rate, maxrate))
+        if (vorbis_encode_setup_managed(vi, avccontext->channels,
+                                        avccontext->sample_rate, minrate,
+                                        avccontext->bit_rate, maxrate))
             return -1;
 
         /* variable bitrate by estimate, disable slow rate management */
-        if(minrate == -1 && maxrate == -1)
-            if(vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE2_SET, NULL))
+        if (minrate == -1 && maxrate == -1)
+            if (vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE2_SET, NULL))
                 return -1;
     }
 
     /* cutoff frequency */
-    if(avccontext->cutoff > 0) {
+    if (avccontext->cutoff > 0) {
         cfreq = avccontext->cutoff / 1000.0;
-        if(vorbis_encode_ctl(vi, OV_ECTL_LOWPASS_SET, &cfreq))
+        if (vorbis_encode_ctl(vi, OV_ECTL_LOWPASS_SET, &cfreq))
             return -1;
     }
 
-    if(context->iblock){
+    if (context->iblock) {
         vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock);
     }
 
@@ -130,35 +132,39 @@ static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avcco
 }
 
 /* How many bytes are needed for a buffer of length 'l' */
-static int xiph_len(int l) { return (1 + l / 255 + l); }
+static int xiph_len(int l)
+{
+    return (1 + l / 255 + l);
+}
 
-static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext) {
-    OggVorbisContext *context = avccontext->priv_data ;
+static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext)
+{
+    OggVorbisContext *context = avccontext->priv_data;
     ogg_packet header, header_comm, header_code;
     uint8_t *p;
     unsigned int offset;
 
-    vorbis_info_init(&context->vi) ;
-    if(oggvorbis_init_encoder(&context->vi, avccontext) < 0) {
-        av_log(avccontext, AV_LOG_ERROR, "oggvorbis_encode_init: init_encoder failed\n") ;
-        return -1 ;
+    vorbis_info_init(&context->vi);
+    if (oggvorbis_init_encoder(&context->vi, avccontext) < 0) {
+        av_log(avccontext, AV_LOG_ERROR, "oggvorbis_encode_init: init_encoder failed\n");
+        return -1;
     }
-    vorbis_analysis_init(&context->vd, &context->vi) ;
-    vorbis_block_init(&context->vd, &context->vb) ;
+    vorbis_analysis_init(&context->vd, &context->vi);
+    vorbis_block_init(&context->vd, &context->vb);
 
     vorbis_comment_init(&context->vc);
-    vorbis_comment_add_tag(&context->vc, "encoder", LIBAVCODEC_IDENT) ;
+    vorbis_comment_add_tag(&context->vc, "encoder", LIBAVCODEC_IDENT);
 
     vorbis_analysis_headerout(&context->vd, &context->vc, &header,
-                                &header_comm, &header_code);
+                              &header_comm, &header_code);
 
-    avccontext->extradata_size=
+    avccontext->extradata_size =
         1 + xiph_len(header.bytes) + xiph_len(header_comm.bytes) +
         header_code.bytes;
     p = avccontext->extradata =
-      av_malloc(avccontext->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
-    p[0] = 2;
-    offset = 1;
+            av_malloc(avccontext->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+    p[0]    = 2;
+    offset  = 1;
     offset += av_xiphlacing(&p[offset], header.bytes);
     offset += av_xiphlacing(&p[offset], header_comm.bytes);
     memcpy(&p[offset], header.packet, header.bytes);
@@ -169,56 +175,57 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext) {
     offset += header_code.bytes;
     assert(offset == avccontext->extradata_size);
 
-/*    vorbis_block_clear(&context->vb);
+#if 0
+    vorbis_block_clear(&context->vb);
     vorbis_dsp_clear(&context->vd);
-    vorbis_info_clear(&context->vi);*/
+    vorbis_info_clear(&context->vi);
+#endif
     vorbis_comment_clear(&context->vc);
 
-    avccontext->frame_size = OGGVORBIS_FRAME_SIZE ;
+    avccontext->frame_size = OGGVORBIS_FRAME_SIZE;
 
-    avccontext->coded_frame= avcodec_alloc_frame();
-    avccontext->coded_frame->key_frame= 1;
+    avccontext->coded_frame = avcodec_alloc_frame();
+    avccontext->coded_frame->key_frame = 1;
 
-    return 0 ;
+    return 0;
 }
 
-
 static int oggvorbis_encode_frame(AVCodecContext *avccontext,
                                   unsigned char *packets,
-                           int buf_size, void *data)
+                                  int buf_size, void *data)
 {
-    OggVorbisContext *context = avccontext->priv_data ;
-    ogg_packet op ;
-    signed short *audio = data ;
+    OggVorbisContext *context = avccontext->priv_data;
+    ogg_packet op;
+    signed short *audio = data;
     int l;
 
-    if(data) {
+    if (data) {
         const int samples = avccontext->frame_size;
-        float **buffer ;
+        float **buffer;
         int c, channels = context->vi.channels;
 
-        buffer = vorbis_analysis_buffer(&context->vd, samples) ;
+        buffer = vorbis_analysis_buffer(&context->vd, samples);
         for (c = 0; c < channels; c++) {
             int co = (channels > 8) ? c :
-                ff_vorbis_encoding_channel_layout_offsets[channels-1][c];
-            for(l = 0 ; l < samples ; l++)
-                buffer[c][l]=audio[l*channels+co]/32768.f;
+                     ff_vorbis_encoding_channel_layout_offsets[channels - 1][c];
+            for (l = 0; l < samples; l++)
+                buffer[c][l] = audio[l * channels + co] / 32768.f;
         }
-        vorbis_analysis_wrote(&context->vd, samples) ;
+        vorbis_analysis_wrote(&context->vd, samples);
     } else {
-        if(!context->eof)
-            vorbis_analysis_wrote(&context->vd, 0) ;
+        if (!context->eof)
+            vorbis_analysis_wrote(&context->vd, 0);
         context->eof = 1;
     }
 
-    while(vorbis_analysis_blockout(&context->vd, &context->vb) == 1) {
+    while (vorbis_analysis_blockout(&context->vd, &context->vb) == 1) {
         vorbis_analysis(&context->vb, NULL);
-        vorbis_bitrate_addblock(&context->vb) ;
+        vorbis_bitrate_addblock(&context->vb);
 
-        while(vorbis_bitrate_flushpacket(&context->vd, &op)) {
+        while (vorbis_bitrate_flushpacket(&context->vd, &op)) {
             /* i'd love to say the following line is a hack, but sadly it's
              * not, apparently the end of stream decision is in libogg. */
-            if(op.bytes==1 && op.e_o_s)
+            if (op.bytes == 1 && op.e_o_s)
                 continue;
             if (context->buffer_index + sizeof(ogg_packet) + op.bytes > BUFFER_SIZE) {
                 av_log(avccontext, AV_LOG_ERROR, "libvorbis: buffer overflow.");
@@ -232,13 +239,13 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
         }
     }
 
-    l=0;
-    if(context->buffer_index){
-        ogg_packet *op2= (ogg_packet*)context->buffer;
+    l = 0;
+    if (context->buffer_index) {
+        ogg_packet *op2 = (ogg_packet *)context->buffer;
         op2->packet = context->buffer + sizeof(ogg_packet);
 
-        l=  op2->bytes;
-        avccontext->coded_frame->pts= av_rescale_q(op2->granulepos, (AVRational){1, avccontext->sample_rate}, avccontext->time_base);
+        l = op2->bytes;
+        avccontext->coded_frame->pts = av_rescale_q(op2->granulepos, (AVRational) { 1, avccontext->sample_rate }, avccontext->time_base);
         //FIXME we should reorder the user supplied pts and not assume that they are spaced by 1/sample_rate
 
         if (l > buf_size) {
@@ -255,12 +262,12 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
     return l;
 }
 
-
-static av_cold int oggvorbis_encode_close(AVCodecContext *avccontext) {
-    OggVorbisContext *context = avccontext->priv_data ;
+static av_cold int oggvorbis_encode_close(AVCodecContext *avccontext)
+{
+    OggVorbisContext *context = avccontext->priv_data;
 /*  ogg_packet op ; */
 
-    vorbis_analysis_wrote(&context->vd, 0) ; /* notify vorbisenc this is EOF */
+    vorbis_analysis_wrote(&context->vd, 0);  /* notify vorbisenc this is EOF */
 
     vorbis_block_clear(&context->vb);
     vorbis_dsp_clear(&context->vd);
@@ -269,10 +276,9 @@ static av_cold int oggvorbis_encode_close(AVCodecContext *avccontext) {
     av_freep(&avccontext->coded_frame);
     av_freep(&avccontext->extradata);
 
-    return 0 ;
+    return 0;
 }
 
-
 AVCodec ff_libvorbis_encoder = {
     .name           = "libvorbis",
     .type           = AVMEDIA_TYPE_AUDIO,
@@ -282,7 +288,7 @@ AVCodec ff_libvorbis_encoder = {
     .encode         = oggvorbis_encode_frame,
     .close          = oggvorbis_encode_close,
     .capabilities   = CODEC_CAP_DELAY,
-    .sample_fmts    = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
+    .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE },
     .long_name      = NULL_IF_CONFIG_SMALL("libvorbis Vorbis"),
     .priv_class     = &class,
 };

File diff suppressed because it is too large
+ 527 - 390
libavcodec/mpegvideo_enc.c


+ 15 - 6
libavformat/applehttp.c

@@ -376,13 +376,23 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size)
 
 restart:
     if (!v->input) {
-reload:
-        /* If this is a live stream and target_duration has elapsed since
+        /* If this is a live stream and the reload interval has elapsed since
          * the last playlist reload, reload the variant playlists now. */
+        int64_t reload_interval = v->n_segments > 0 ?
+                                  v->segments[v->n_segments - 1]->duration :
+                                  v->target_duration;
+        reload_interval *= 1000000;
+
+reload:
         if (!v->finished &&
-            av_gettime() - v->last_load_time >= v->target_duration*1000000 &&
-            (ret = parse_playlist(c, v->url, v, NULL)) < 0)
+            av_gettime() - v->last_load_time >= reload_interval) {
+            if ((ret = parse_playlist(c, v->url, v, NULL)) < 0)
                 return ret;
+            /* If we need to reload the playlist again below (if
+             * there's still no more segments), switch to a reload
+             * interval of half the target duration. */
+            reload_interval = v->target_duration * 500000;
+        }
         if (v->cur_seq_no < v->start_seq_no) {
             av_log(NULL, AV_LOG_WARNING,
                    "skipping %d segments ahead, expired from playlists\n",
@@ -392,8 +402,7 @@ reload:
         if (v->cur_seq_no >= v->start_seq_no + v->n_segments) {
             if (v->finished)
                 return AVERROR_EOF;
-            while (av_gettime() - v->last_load_time <
-                   v->target_duration*1000000) {
+            while (av_gettime() - v->last_load_time < reload_interval) {
                 if (ff_check_interrupt(c->interrupt_callback))
                     return AVERROR_EXIT;
                 usleep(100*1000);

+ 12 - 2
libavformat/applehttpproto.c

@@ -244,6 +244,7 @@ static int applehttp_read(URLContext *h, uint8_t *buf, int size)
     AppleHTTPContext *s = h->priv_data;
     const char *url;
     int ret;
+    int64_t reload_interval;
 
 start:
     if (s->seg_hd) {
@@ -256,12 +257,21 @@ start:
         s->seg_hd = NULL;
         s->cur_seq_no++;
     }
+    reload_interval = s->n_segments > 0 ?
+                      s->segments[s->n_segments - 1]->duration :
+                      s->target_duration;
+    reload_interval *= 1000000;
 retry:
     if (!s->finished) {
         int64_t now = av_gettime();
-        if (now - s->last_load_time >= s->target_duration*1000000)
+        if (now - s->last_load_time >= reload_interval) {
             if ((ret = parse_playlist(h, s->playlisturl)) < 0)
                 return ret;
+            /* If we need to reload the playlist again below (if
+             * there's still no more segments), switch to a reload
+             * interval of half the target duration. */
+            reload_interval = s->target_duration * 500000;
+        }
     }
     if (s->cur_seq_no < s->start_seq_no) {
         av_log(h, AV_LOG_WARNING,
@@ -272,7 +282,7 @@ retry:
     if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {
         if (s->finished)
             return AVERROR_EOF;
-        while (av_gettime() - s->last_load_time < s->target_duration*1000000) {
+        while (av_gettime() - s->last_load_time < reload_interval) {
             if (ff_check_interrupt(&h->interrupt_callback))
                 return AVERROR_EXIT;
             usleep(100*1000);

+ 2 - 0
tests/Makefile

@@ -50,6 +50,7 @@ include $(SRC_PATH)/tests/fate/amrnb.mak
 include $(SRC_PATH)/tests/fate/amrwb.mak
 include $(SRC_PATH)/tests/fate/atrac.mak
 include $(SRC_PATH)/tests/fate/dct.mak
+include $(SRC_PATH)/tests/fate/dpcm.mak
 include $(SRC_PATH)/tests/fate/fft.mak
 include $(SRC_PATH)/tests/fate/h264.mak
 include $(SRC_PATH)/tests/fate/image.mak
@@ -62,6 +63,7 @@ include $(SRC_PATH)/tests/fate/lossless-video.mak
 include $(SRC_PATH)/tests/fate/microsoft.mak
 include $(SRC_PATH)/tests/fate/mp3.mak
 include $(SRC_PATH)/tests/fate/mpc.mak
+include $(SRC_PATH)/tests/fate/pcm.mak
 include $(SRC_PATH)/tests/fate/prores.mak
 include $(SRC_PATH)/tests/fate/qtrle.mak
 include $(SRC_PATH)/tests/fate/real.mak

Some files were not shown because too many files changed in this diff