Browse Source

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  mss3: use standard zigzag table
  mss3: split DSP functions that are used in MTS2(MSS4) into separate file
  motion-test: do not use getopt()
  tcp: add initial timeout limit for incoming connections
  configure: Change the rdtsc check to a linker check
  avconv: propagate fatal errors from lavfi.
  lavfi: add error handling to filter_samples().
  fate-run: make avconv() properly deal with multiple inputs.
  asplit: don't leak the input buffer.
  af_resample: fix request_frame() behavior.
  af_asyncts: fix request_frame() behavior.
  libx264: support aspect ratio switching
  matroskadec: honor error_recognition when encountering unknown elements.
  lavr: resampling: add support for s32p, fltp, and dblp internal sample formats
  lavr: resampling: add filter type and Kaiser window beta to AVOptions
  lavr: Use AV_SAMPLE_FMT_NONE to auto-select the internal sample format
  lavr: mix: validate internal sample format in ff_audio_mix_init()

Conflicts:
	ffmpeg.c
	ffplay.c
	libavcodec/libx264.c
	libavfilter/audio.c
	libavfilter/split.c
	libavformat/tcp.c
	tests/fate-run.sh

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Michael Niedermayer 12 years ago
parent
commit
f8911b987d

+ 1 - 1
libavcodec/Makefile

@@ -327,7 +327,7 @@ OBJS-$(CONFIG_MSMPEG4V3_ENCODER)       += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
                                           h263dec.o h263.o ituh263dec.o        \
                                           mpeg4videodec.o
 OBJS-$(CONFIG_MSRLE_DECODER)           += msrle.o msrledec.o
-OBJS-$(CONFIG_MSA1_DECODER)            += mss3.o
+OBJS-$(CONFIG_MSA1_DECODER)            += mss3.o mss34dsp.o
 OBJS-$(CONFIG_MSS1_DECODER)            += mss1.o
 OBJS-$(CONFIG_MSVIDEO1_DECODER)        += msvideo1.o
 OBJS-$(CONFIG_MSVIDEO1_ENCODER)        += msvideo1enc.o elbg.o

+ 3 - 3
libavcodec/libx264.c

@@ -175,10 +175,10 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
             x4->params.b_tff = frame->top_field_first;
             x264_encoder_reconfig(x4->enc, &x4->params);
         }
-        if (x4->params.vui.i_sar_height != ctx->sample_aspect_ratio.den
-         || x4->params.vui.i_sar_width != ctx->sample_aspect_ratio.num) {
+        if (x4->params.vui.i_sar_height != ctx->sample_aspect_ratio.den ||
+            x4->params.vui.i_sar_width  != ctx->sample_aspect_ratio.num) {
             x4->params.vui.i_sar_height = ctx->sample_aspect_ratio.den;
-            x4->params.vui.i_sar_width = ctx->sample_aspect_ratio.num;
+            x4->params.vui.i_sar_width  = ctx->sample_aspect_ratio.num;
             x264_encoder_reconfig(x4->enc, &x4->params);
         }
     }

+ 3 - 9
libavcodec/motion-test.c

@@ -119,15 +119,9 @@ int main(int argc, char **argv)
     int flags[2] = { AV_CPU_FLAG_MMX, AV_CPU_FLAG_MMX2 };
     int flags_size = HAVE_MMX2 ? 2 : 1;
 
-    for(;;) {
-        c = getopt(argc, argv, "h");
-        if (c == -1)
-            break;
-        switch(c) {
-        case 'h':
-            help();
-            return 1;
-        }
+    if (argc > 1) {
+        help();
+        return 1;
     }
 
     printf("ffmpeg motion test\n");

+ 5 - 103
libavcodec/mss3.c

@@ -26,6 +26,8 @@
 
 #include "avcodec.h"
 #include "bytestream.h"
+#include "dsputil.h"
+#include "mss34dsp.h"
 
 #define HEADER_SIZE 27
 
@@ -119,39 +121,6 @@ typedef struct MSS3Context {
     int              hblock[16 * 16];
 } MSS3Context;
 
-static const uint8_t mss3_luma_quant[64] = {
-    16,  11,  10,  16,  24,  40,  51,  61,
-    12,  12,  14,  19,  26,  58,  60,  55,
-    14,  13,  16,  24,  40,  57,  69,  56,
-    14,  17,  22,  29,  51,  87,  80,  62,
-    18,  22,  37,  56,  68, 109, 103,  77,
-    24,  35,  55,  64,  81, 104, 113,  92,
-    49,  64,  78,  87, 103, 121, 120, 101,
-    72,  92,  95,  98, 112, 100, 103,  99
-};
-
-static const uint8_t mss3_chroma_quant[64] = {
-    17, 18, 24, 47, 99, 99, 99, 99,
-    18, 21, 26, 66, 99, 99, 99, 99,
-    24, 26, 56, 99, 99, 99, 99, 99,
-    47, 66, 99, 99, 99, 99, 99, 99,
-    99, 99, 99, 99, 99, 99, 99, 99,
-    99, 99, 99, 99, 99, 99, 99, 99,
-    99, 99, 99, 99, 99, 99, 99, 99,
-    99, 99, 99, 99, 99, 99, 99, 99
-};
-
-static const uint8_t zigzag_scan[64] = {
-    0,   1,  8, 16,  9,  2,  3, 10,
-    17, 24, 32, 25, 18, 11,  4,  5,
-    12, 19, 26, 33, 40, 48, 41, 34,
-    27, 20, 13,  6,  7, 14, 21, 28,
-    35, 42, 49, 56, 57, 50, 43, 36,
-    29, 22, 15, 23, 30, 37, 44, 51,
-    58, 59, 52, 45, 38, 31, 39, 46,
-    53, 60, 61, 54, 47, 55, 62, 63
-};
-
 
 static void model2_reset(Model2 *m)
 {
@@ -578,7 +547,7 @@ static int decode_dct(RangeCoder *c, DCTBlockCoder *bc, int *block,
         if (!sign)
             val = -val;
 
-        zz_pos = zigzag_scan[pos];
+        zz_pos = ff_zigzag_direct[pos];
         block[zz_pos] = val * bc->qmat[zz_pos];
         pos++;
     }
@@ -586,58 +555,6 @@ static int decode_dct(RangeCoder *c, DCTBlockCoder *bc, int *block,
     return pos == 64 ? 0 : -1;
 }
 
-#define DCT_TEMPLATE(blk, step, SOP, shift)                         \
-    const int t0 = -39409 * blk[7 * step] -  58980 * blk[1 * step]; \
-    const int t1 =  39410 * blk[1 * step] -  58980 * blk[7 * step]; \
-    const int t2 = -33410 * blk[5 * step] - 167963 * blk[3 * step]; \
-    const int t3 =  33410 * blk[3 * step] - 167963 * blk[5 * step]; \
-    const int t4 =          blk[3 * step] +          blk[7 * step]; \
-    const int t5 =          blk[1 * step] +          blk[5 * step]; \
-    const int t6 =  77062 * t4            +  51491 * t5;            \
-    const int t7 =  77062 * t5            -  51491 * t4;            \
-    const int t8 =  35470 * blk[2 * step] -  85623 * blk[6 * step]; \
-    const int t9 =  35470 * blk[6 * step] +  85623 * blk[2 * step]; \
-    const int tA = SOP(blk[0 * step] - blk[4 * step]);              \
-    const int tB = SOP(blk[0 * step] + blk[4 * step]);              \
-                                                                    \
-    blk[0 * step] = (  t1 + t6  + t9 + tB) >> shift;                \
-    blk[1 * step] = (  t3 + t7  + t8 + tA) >> shift;                \
-    blk[2 * step] = (  t2 + t6  - t8 + tA) >> shift;                \
-    blk[3 * step] = (  t0 + t7  - t9 + tB) >> shift;                \
-    blk[4 * step] = (-(t0 + t7) - t9 + tB) >> shift;                \
-    blk[5 * step] = (-(t2 + t6) - t8 + tA) >> shift;                \
-    blk[6 * step] = (-(t3 + t7) + t8 + tA) >> shift;                \
-    blk[7 * step] = (-(t1 + t6) + t9 + tB) >> shift;                \
-
-#define SOP_ROW(a) ((a) << 16) + 0x2000
-#define SOP_COL(a) ((a + 32) << 16)
-
-static void dct_put(uint8_t *dst, int stride, int *block)
-{
-    int i, j;
-    int *ptr;
-
-    ptr = block;
-    for (i = 0; i < 8; i++) {
-        DCT_TEMPLATE(ptr, 1, SOP_ROW, 13);
-        ptr += 8;
-    }
-
-    ptr = block;
-    for (i = 0; i < 8; i++) {
-        DCT_TEMPLATE(ptr, 8, SOP_COL, 22);
-        ptr++;
-    }
-
-    ptr = block;
-    for (j = 0; j < 8; j++) {
-        for (i = 0; i < 8; i++)
-            dst[i] = av_clip_uint8(ptr[i] + 128);
-        dst += stride;
-        ptr += 8;
-    }
-}
-
 static void decode_dct_block(RangeCoder *c, DCTBlockCoder *bc,
                              uint8_t *dst, int stride, int block_size,
                              int *block, int mb_x, int mb_y)
@@ -655,7 +572,7 @@ static void decode_dct_block(RangeCoder *c, DCTBlockCoder *bc,
                 c->got_error = 1;
                 return;
             }
-            dct_put(dst + i * 8, stride, block);
+            ff_mss34_dct_put(dst + i * 8, stride, block);
         }
         dst += 8 * stride;
     }
@@ -702,14 +619,6 @@ static void decode_haar_block(RangeCoder *c, HaarBlockCoder *hc,
     }
 }
 
-static void gen_quant_mat(uint16_t *qmat, const uint8_t *ref, float scale)
-{
-    int i;
-
-    for (i = 0; i < 64; i++)
-        qmat[i] = (uint16_t)(ref[i] * scale + 50.0) / 100;
-}
-
 static void reset_coders(MSS3Context *ctx, int quality)
 {
     int i, j;
@@ -726,15 +635,8 @@ static void reset_coders(MSS3Context *ctx, int quality)
         for (j = 0; j < 125; j++)
             model_reset(&ctx->image_coder[i].vq_model[j]);
         if (ctx->dct_coder[i].quality != quality) {
-            float scale;
             ctx->dct_coder[i].quality = quality;
-            if (quality > 50)
-                scale = 200.0f - 2 * quality;
-            else
-                scale = 5000.0f / quality;
-            gen_quant_mat(ctx->dct_coder[i].qmat,
-                          i ? mss3_chroma_quant : mss3_luma_quant,
-                          scale);
+            ff_mss34_gen_quant_mat(ctx->dct_coder[i].qmat, quality, !i);
         }
         memset(ctx->dct_coder[i].prev_dc, 0,
                sizeof(*ctx->dct_coder[i].prev_dc) *

+ 114 - 0
libavcodec/mss34dsp.c

@@ -0,0 +1,114 @@
+/*
+ * Common stuff for some Microsoft Screen codecs
+ * Copyright (C) 2012 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+#include "libavutil/common.h"
+#include "mss34dsp.h"
+
+static const uint8_t luma_quant[64] = {
+    16,  11,  10,  16,  24,  40,  51,  61,
+    12,  12,  14,  19,  26,  58,  60,  55,
+    14,  13,  16,  24,  40,  57,  69,  56,
+    14,  17,  22,  29,  51,  87,  80,  62,
+    18,  22,  37,  56,  68, 109, 103,  77,
+    24,  35,  55,  64,  81, 104, 113,  92,
+    49,  64,  78,  87, 103, 121, 120, 101,
+    72,  92,  95,  98, 112, 100, 103,  99
+};
+
+static const uint8_t chroma_quant[64] = {
+    17, 18, 24, 47, 99, 99, 99, 99,
+    18, 21, 26, 66, 99, 99, 99, 99,
+    24, 26, 56, 99, 99, 99, 99, 99,
+    47, 66, 99, 99, 99, 99, 99, 99,
+    99, 99, 99, 99, 99, 99, 99, 99,
+    99, 99, 99, 99, 99, 99, 99, 99,
+    99, 99, 99, 99, 99, 99, 99, 99,
+    99, 99, 99, 99, 99, 99, 99, 99
+};
+
+void ff_mss34_gen_quant_mat(uint16_t *qmat, int quality, int luma)
+{
+    int i;
+    const uint8_t *qsrc = luma ? luma_quant : chroma_quant;
+
+    if (quality >= 50) {
+        int scale = 200 - 2 * quality;
+
+        for (i = 0; i < 64; i++)
+            qmat[i] = (qsrc[i] * scale + 50) / 100;
+    } else {
+        for (i = 0; i < 64; i++)
+            qmat[i] = (5000 * qsrc[i] / quality + 50) / 100;
+    }
+}
+
+#define DCT_TEMPLATE(blk, step, SOP, shift)                         \
+    const int t0 = -39409 * blk[7 * step] -  58980 * blk[1 * step]; \
+    const int t1 =  39410 * blk[1 * step] -  58980 * blk[7 * step]; \
+    const int t2 = -33410 * blk[5 * step] - 167963 * blk[3 * step]; \
+    const int t3 =  33410 * blk[3 * step] - 167963 * blk[5 * step]; \
+    const int t4 =          blk[3 * step] +          blk[7 * step]; \
+    const int t5 =          blk[1 * step] +          blk[5 * step]; \
+    const int t6 =  77062 * t4            +  51491 * t5;            \
+    const int t7 =  77062 * t5            -  51491 * t4;            \
+    const int t8 =  35470 * blk[2 * step] -  85623 * blk[6 * step]; \
+    const int t9 =  35470 * blk[6 * step] +  85623 * blk[2 * step]; \
+    const int tA = SOP(blk[0 * step] - blk[4 * step]);              \
+    const int tB = SOP(blk[0 * step] + blk[4 * step]);              \
+                                                                    \
+    blk[0 * step] = (  t1 + t6  + t9 + tB) >> shift;                \
+    blk[1 * step] = (  t3 + t7  + t8 + tA) >> shift;                \
+    blk[2 * step] = (  t2 + t6  - t8 + tA) >> shift;                \
+    blk[3 * step] = (  t0 + t7  - t9 + tB) >> shift;                \
+    blk[4 * step] = (-(t0 + t7) - t9 + tB) >> shift;                \
+    blk[5 * step] = (-(t2 + t6) - t8 + tA) >> shift;                \
+    blk[6 * step] = (-(t3 + t7) + t8 + tA) >> shift;                \
+    blk[7 * step] = (-(t1 + t6) + t9 + tB) >> shift;                \
+
+#define SOP_ROW(a) ((a) << 16) + 0x2000
+#define SOP_COL(a) ((a + 32) << 16)
+
+void ff_mss34_dct_put(uint8_t *dst, int stride, int *block)
+{
+    int i, j;
+    int *ptr;
+
+    ptr = block;
+    for (i = 0; i < 8; i++) {
+        DCT_TEMPLATE(ptr, 1, SOP_ROW, 13);
+        ptr += 8;
+    }
+
+    ptr = block;
+    for (i = 0; i < 8; i++) {
+        DCT_TEMPLATE(ptr, 8, SOP_COL, 22);
+        ptr++;
+    }
+
+    ptr = block;
+    for (j = 0; j < 8; j++) {
+        for (i = 0; i < 8; i++)
+            dst[i] = av_clip_uint8(ptr[i] + 128);
+        dst += stride;
+        ptr += 8;
+    }
+}

+ 45 - 0
libavcodec/mss34dsp.h

@@ -0,0 +1,45 @@
+/*
+ * Common stuff for some Microsoft Screen codecs
+ * Copyright (C) 2012 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_MSS34DSP_H
+#define AVCODEC_MSS34DSP_H
+
+#include <stdint.h>
+
+/**
+ * Generate quantisation matrix for given quality.
+ *
+ * @param qmat    destination matrix
+ * @param quality quality setting (1-100)
+ * @param luma    generate quantisation matrix for luma or chroma
+ */
+void ff_mss34_gen_quant_mat(uint16_t *qmat, int quality, int luma);
+
+/**
+ * Transform and output DCT block.
+ *
+ * @param dst     output plane
+ * @param stride  output plane stride
+ * @param block   block to transform and output
+ */
+void ff_mss34_dct_put(uint8_t *dst, int stride, int *block);
+
+#endif /* AVCODEC_MSS34DSP_H */

+ 4 - 2
libavfilter/af_aconvert.c

@@ -135,12 +135,13 @@ static int config_output(AVFilterLink *outlink)
     return 0;
 }
 
-static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref)
+static int  filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref)
 {
     AConvertContext *aconvert = inlink->dst->priv;
     const int n = insamplesref->audio->nb_samples;
     AVFilterLink *const outlink = inlink->dst->outputs[0];
     AVFilterBufferRef *outsamplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n);
+    int ret;
 
     swr_convert(aconvert->swr, outsamplesref->data, n,
                         (void *)insamplesref->data, n);
@@ -148,8 +149,9 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
     avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
     outsamplesref->audio->channel_layout = outlink->channel_layout;
 
-    ff_filter_samples(outlink, outsamplesref);
+    ret = ff_filter_samples(outlink, outsamplesref);
     avfilter_unref_buffer(insamplesref);
+    return ret;
 }
 
 AVFilter avfilter_af_aconvert = {

+ 3 - 3
libavfilter/af_amerge.c

@@ -212,7 +212,7 @@ static inline void copy_samples(int nb_inputs, struct amerge_input in[],
     }
 }
 
-static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
+static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
 {
     AVFilterContext *ctx = inlink->dst;
     AMergeContext *am = ctx->priv;
@@ -232,7 +232,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
     for (i = 1; i < am->nb_inputs; i++)
         nb_samples = FFMIN(nb_samples, am->in[i].nb_samples);
     if (!nb_samples)
-        return;
+        return 0;
 
     outbuf = ff_get_audio_buffer(ctx->outputs[0], AV_PERM_WRITE, nb_samples);
     outs = outbuf->data[0];
@@ -285,7 +285,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
             }
         }
     }
-    ff_filter_samples(ctx->outputs[0], outbuf);
+    return ff_filter_samples(ctx->outputs[0], outbuf);
 }
 
 static av_cold int init(AVFilterContext *ctx, const char *args)

+ 13 - 9
libavfilter/af_amix.c

@@ -305,9 +305,7 @@ static int output_frame(AVFilterLink *outlink, int nb_samples)
     if (s->next_pts != AV_NOPTS_VALUE)
         s->next_pts += nb_samples;
 
-    ff_filter_samples(outlink, out_buf);
-
-    return 0;
+    return ff_filter_samples(outlink, out_buf);
 }
 
 /**
@@ -448,31 +446,37 @@ static int request_frame(AVFilterLink *outlink)
     return output_frame(outlink, available_samples);
 }
 
-static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
+static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
 {
     AVFilterContext  *ctx = inlink->dst;
     MixContext       *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
-    int i;
+    int i, ret = 0;
 
     for (i = 0; i < ctx->nb_inputs; i++)
         if (ctx->inputs[i] == inlink)
             break;
     if (i >= ctx->nb_inputs) {
         av_log(ctx, AV_LOG_ERROR, "unknown input link\n");
-        return;
+        ret = AVERROR(EINVAL);
+        goto fail;
     }
 
     if (i == 0) {
         int64_t pts = av_rescale_q(buf->pts, inlink->time_base,
                                    outlink->time_base);
-        frame_list_add_frame(s->frame_list, buf->audio->nb_samples, pts);
+        ret = frame_list_add_frame(s->frame_list, buf->audio->nb_samples, pts);
+        if (ret < 0)
+            goto fail;
     }
 
-    av_audio_fifo_write(s->fifos[i], (void **)buf->extended_data,
-                        buf->audio->nb_samples);
+    ret = av_audio_fifo_write(s->fifos[i], (void **)buf->extended_data,
+                              buf->audio->nb_samples);
 
+fail:
     avfilter_unref_buffer(buf);
+
+    return ret;
 }
 
 static int init(AVFilterContext *ctx, const char *args)

+ 5 - 3
libavfilter/af_aresample.c

@@ -168,13 +168,14 @@ static int config_output(AVFilterLink *outlink)
     return 0;
 }
 
-static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref)
+static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref)
 {
     AResampleContext *aresample = inlink->dst->priv;
     const int n_in  = insamplesref->audio->nb_samples;
     int n_out       = n_in * aresample->ratio * 2 ;
     AVFilterLink *const outlink = inlink->dst->outputs[0];
     AVFilterBufferRef *outsamplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n_out);
+    int ret;
 
 
     avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
@@ -193,15 +194,16 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
     if (n_out <= 0) {
         avfilter_unref_buffer(outsamplesref);
         avfilter_unref_buffer(insamplesref);
-        return;
+        return 0;
     }
 
     outsamplesref->audio->sample_rate = outlink->sample_rate;
     outsamplesref->audio->nb_samples  = n_out;
 
-    ff_filter_samples(outlink, outsamplesref);
+    ret = ff_filter_samples(outlink, outsamplesref);
     aresample->req_fullfilled= 1;
     avfilter_unref_buffer(insamplesref);
+    return ret;
 }
 
 static int request_frame(AVFilterLink *outlink)

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