]> git.sesse.net Git - ffmpeg/commitdiff
Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 11 Apr 2012 20:50:22 +0000 (22:50 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 11 Apr 2012 20:50:22 +0000 (22:50 +0200)
* qatar/master:
  avplay: Don't free video filters string until the end of decoding.
  movenc: small refactor mov_write_packet
  movenc: remove redundant check
  interplayvideo: fix av_dlog parameter type mismatch
  Drop some pointless #ifdefs.

Conflicts:
libavcodec/interplayvideo.c
libavcodec/libxvidff.c
libavcodec/snowenc.c
libavformat/movenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
ffplay.c
libavcodec/interplayvideo.c
libavcodec/libxvidff.c
libavcodec/snowenc.c
libavformat/movenc.c
libavformat/nutdec.c

diff --cc ffplay.c
Simple merge
Simple merge
index 33cf997e17925d667700d12e1311bcf332f56390,344f6033ffa2e7b92f39fb827b79d3c10aeb344a..811efc3793ca601b08b7f436c4948f3151892b98
@@@ -77,7 -78,41 +77,6 @@@ int xvid_strip_vol_header(AVCodecContex
  int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2);
  void xvid_correct_framerate(AVCodecContext *avctx);
  
- #if CONFIG_LIBXVID_ENCODER
 -/* Wrapper to work around the lack of mkstemp() on mingw.
 - * Also, tries to create file in /tmp first, if possible.
 - * *prefix can be a character constant; *filename will be allocated internally.
 - * @return file descriptor of opened file (or -1 on error)
 - * and opened file name in **filename. */
 -int ff_tempfile(const char *prefix, char **filename) {
 -    int fd=-1;
 -#if !HAVE_MKSTEMP
 -    *filename = tempnam(".", prefix);
 -#else
 -    size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */
 -    *filename = av_malloc(len);
 -#endif
 -    /* -----common section-----*/
 -    if (*filename == NULL) {
 -        av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
 -        return -1;
 -    }
 -#if !HAVE_MKSTEMP
 -    fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
 -#else
 -    snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
 -    fd = mkstemp(*filename);
 -    if (fd < 0) {
 -        snprintf(*filename, len, "./%sXXXXXX", prefix);
 -        fd = mkstemp(*filename);
 -    }
 -#endif
 -    /* -----common section-----*/
 -    if (fd < 0) {
 -        av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
 -        return -1;
 -    }
 -    return fd; /* success */
 -}
  
  /**
   * Create the private context for the encoder.
index 61acf85615c891e363f3238b3c2c408dae43874a,7b010e1f1c86c0529bba483ef68b77b1f85888d7..ea66d5fd9cedeed1a1001e2ac71005d6a4b3f551
@@@ -1927,125 -1924,3 +1926,124 @@@ AVCodec ff_snow_encoder = 
      .long_name      = NULL_IF_CONFIG_SMALL("Snow"),
      .priv_class     = &snowenc_class,
  };
- #endif
 +
 +
 +#ifdef TEST
 +#undef malloc
 +#undef free
 +#undef printf
 +
 +#include "libavutil/lfg.h"
 +#include "libavutil/mathematics.h"
 +
 +int main(void){
 +    int width=256;
 +    int height=256;
 +    int buffer[2][width*height];
 +    SnowContext s;
 +    int i;
 +    AVLFG prng;
 +    s.spatial_decomposition_count=6;
 +    s.spatial_decomposition_type=1;
 +
 +    av_lfg_init(&prng, 1);
 +
 +    printf("testing 5/3 DWT\n");
 +    for(i=0; i<width*height; i++)
 +        buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345;
 +
 +    ff_spatial_dwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +    ff_spatial_idwt((IDWTELEM*)buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +
 +    for(i=0; i<width*height; i++)
 +        if(buffer[0][i]!= buffer[1][i]) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
 +
 +    printf("testing 9/7 DWT\n");
 +    s.spatial_decomposition_type=0;
 +    for(i=0; i<width*height; i++)
 +        buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345;
 +
 +    ff_spatial_dwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +    ff_spatial_idwt((IDWTELEM*)buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +
 +    for(i=0; i<width*height; i++)
 +        if(FFABS(buffer[0][i] - buffer[1][i])>20) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
 +
 +    {
 +    int level, orientation, x, y;
 +    int64_t errors[8][4];
 +    int64_t g=0;
 +
 +        memset(errors, 0, sizeof(errors));
 +        s.spatial_decomposition_count=3;
 +        s.spatial_decomposition_type=0;
 +        for(level=0; level<s.spatial_decomposition_count; level++){
 +            for(orientation=level ? 1 : 0; orientation<4; orientation++){
 +                int w= width  >> (s.spatial_decomposition_count-level);
 +                int h= height >> (s.spatial_decomposition_count-level);
 +                int stride= width  << (s.spatial_decomposition_count-level);
 +                DWTELEM *buf= buffer[0];
 +                int64_t error=0;
 +
 +                if(orientation&1) buf+=w;
 +                if(orientation>1) buf+=stride>>1;
 +
 +                memset(buffer[0], 0, sizeof(int)*width*height);
 +                buf[w/2 + h/2*stride]= 256*256;
 +                ff_spatial_idwt((IDWTELEM*)buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +                for(y=0; y<height; y++){
 +                    for(x=0; x<width; x++){
 +                        int64_t d= buffer[0][x + y*width];
 +                        error += d*d;
 +                        if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9 && level==2) printf("%8"PRId64" ", d);
 +                    }
 +                    if(FFABS(height/2-y)<9 && level==2) printf("\n");
 +                }
 +                error= (int)(sqrt(error)+0.5);
 +                errors[level][orientation]= error;
 +                if(g) g=av_gcd(g, error);
 +                else g= error;
 +            }
 +        }
 +        printf("static int const visual_weight[][4]={\n");
 +        for(level=0; level<s.spatial_decomposition_count; level++){
 +            printf("  {");
 +            for(orientation=0; orientation<4; orientation++){
 +                printf("%8"PRId64",", errors[level][orientation]/g);
 +            }
 +            printf("},\n");
 +        }
 +        printf("};\n");
 +        {
 +            int level=2;
 +            int w= width  >> (s.spatial_decomposition_count-level);
 +            //int h= height >> (s.spatial_decomposition_count-level);
 +            int stride= width  << (s.spatial_decomposition_count-level);
 +            DWTELEM *buf= buffer[0];
 +            int64_t error=0;
 +
 +            buf+=w;
 +            buf+=stride>>1;
 +
 +            memset(buffer[0], 0, sizeof(int)*width*height);
 +            for(y=0; y<height; y++){
 +                for(x=0; x<width; x++){
 +                    int tab[4]={0,2,3,1};
 +                    buffer[0][x+width*y]= 256*256*tab[(x&1) + 2*(y&1)];
 +                }
 +            }
 +            ff_spatial_dwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +            for(y=0; y<height; y++){
 +                for(x=0; x<width; x++){
 +                    int64_t d= buffer[0][x + y*width];
 +                    error += d*d;
 +                    if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9) printf("%8"PRId64" ", d);
 +                }
 +                if(FFABS(height/2-y)<9) printf("\n");
 +            }
 +        }
 +
 +    }
 +    return 0;
 +}
 +#endif /* TEST */
index 60a8bb1c28128c9b883fc25dc6c9ef942359032e,e4dbbc99da05a0f1e95ea3c37ccfca55a885d52f..1e0dab7e82a2c8ff16c127cc81e34fa96c5f339f
@@@ -3039,7 -2945,29 +3019,29 @@@ static int mov_write_packet(AVFormatCon
          mov_flush_fragment(s);
          return 1;
      } else {
-         return mov_write_packet_internal(s, pkt);
+         MOVMuxContext *mov = s->priv_data;
+         MOVTrack *trk = &mov->tracks[pkt->stream_index];
+         AVCodecContext *enc = trk->enc;
+         int64_t frag_duration = 0;
+         int size = pkt->size;
+         if (!pkt->size) return 0; /* Discard 0 sized packets */
 -        if (trk->entry)
++        if (trk->entry && pkt->stream_index < s->nb_streams)
+             frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
+                                          s->streams[pkt->stream_index]->time_base,
+                                          AV_TIME_BASE_Q);
+         if ((mov->max_fragment_duration &&
+              frag_duration >= mov->max_fragment_duration) ||
+              (mov->max_fragment_size && mov->mdat_size + size >= mov->max_fragment_size) ||
+              (mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&
+               enc->codec_type == AVMEDIA_TYPE_VIDEO &&
+               trk->entry && pkt->flags & AV_PKT_FLAG_KEY)) {
+             if (frag_duration >= mov->min_fragment_duration)
+                 mov_flush_fragment(s);
+         }
+         return ff_mov_write_packet(s, pkt);
      }
  }
  
Simple merge