Commit 3c54e7ed authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  ac3enc: Add channel coupling support for the fixed-point AC-3 encoder.
  ac3enc: scale floating-point coupling channel coefficients in scale_coefficients() rather than in apply_channel_coupling()
  ac3enc: fix encoding of stereo ac3 files when rematrixing is disabled.
  wavpack: fix wrong return value in wavpack_decode_block()
  avconv: fix parsing metadata specifiers.
  fate: use +frame+slice named constants instead of '3'
  mpeg12: propagate more real return values through chunk decode error return and fix some indentation
  wavpack: use context reset in appropriate places
  avconv: move mux_preload and mux_max_delay to options context
  avconv: move bitstream filters to options context.
  avconv: move rate_emu to options context.
  avconv: move max_frames to options context.
  avconv: move metadata to options context.
  avconv: move ts scale to options context.
  avconv: move chapter maps to options context.
  avconv: move metadata maps to options context.
  avconv: move codec_names to options context.

Conflicts:
	avconv.c
	tests/fate-run.sh
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 27bf5993 ae264bb2
This diff is collapsed.
...@@ -259,6 +259,8 @@ unknown_opt: ...@@ -259,6 +259,8 @@ unknown_opt:
*(int64_t*)dst = parse_time_or_die(opt, arg, 1); *(int64_t*)dst = parse_time_or_die(opt, arg, 1);
} else if (po->flags & OPT_FLOAT) { } else if (po->flags & OPT_FLOAT) {
*(float*)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); *(float*)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY);
} else if (po->flags & OPT_DOUBLE) {
*(double*)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY);
} else if (po->u.func_arg) { } else if (po->u.func_arg) {
int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg) : int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg) :
po->u.func_arg(opt, arg); po->u.func_arg(opt, arg);
......
...@@ -119,6 +119,7 @@ typedef struct SpecifierOpt { ...@@ -119,6 +119,7 @@ typedef struct SpecifierOpt {
int i; int i;
int64_t i64; int64_t i64;
float f; float f;
double dbl;
} u; } u;
} SpecifierOpt; } SpecifierOpt;
...@@ -144,6 +145,7 @@ typedef struct { ...@@ -144,6 +145,7 @@ typedef struct {
Implies OPT_OFFSET. Next element after the offset is Implies OPT_OFFSET. Next element after the offset is
an int containing element count in the array. */ an int containing element count in the array. */
#define OPT_TIME 0x10000 #define OPT_TIME 0x10000
#define OPT_DOUBLE 0x20000
union { union {
void *dst_ptr; void *dst_ptr;
int (*func_arg)(const char *, const char *); int (*func_arg)(const char *, const char *);
......
...@@ -160,14 +160,26 @@ interpreted as UTC. ...@@ -160,14 +160,26 @@ interpreted as UTC.
If the year-month-day part is not specified it takes the current If the year-month-day part is not specified it takes the current
year-month-day. year-month-day.
@item -metadata @var{key}=@var{value} @item -metadata[:metadata_specifier] @var{key}=@var{value}
Set a metadata key/value pair. Set a metadata key/value pair.
An optional @var{metadata_specifier} may be given to set metadata
on streams or chapters. See @code{-map_metadata} documentation for
details.
This option overrides metadata set with @code{-map_metadata}. It is
also possible to delete metadata by using an empty value.
For example, for setting the title in the output file: For example, for setting the title in the output file:
@example @example
avconv -i in.avi -metadata title="my title" out.flv avconv -i in.avi -metadata title="my title" out.flv
@end example @end example
To set the language of the second stream:
@example
avconv -i INPUT -metadata:s:1 language=eng OUTPUT
@end example
@item -v @var{number} @item -v @var{number}
Set the logging verbosity level. Set the logging verbosity level.
...@@ -188,18 +200,21 @@ avconv -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg ...@@ -188,18 +200,21 @@ avconv -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
@end example @end example
@item -dframes @var{number} @item -dframes @var{number}
Set the number of data frames to record. Set the number of data frames to record. This is an alias for @code{-frames:d}.
@item -slang @var{code} @item -slang @var{code}
Set the ISO 639 language code (3 letters) of the current subtitle stream. Set the ISO 639 language code (3 letters) of the current subtitle stream.
@item -frames[:stream_specifier] @var{framecount}
Stop writing to the stream after @var{framecount} frames.
@end table @end table
@section Video Options @section Video Options
@table @option @table @option
@item -vframes @var{number} @item -vframes @var{number}
Set the number of video frames to record. Set the number of video frames to record. This is an alias for @code{-frames:v}.
@item -r @var{fps} @item -r @var{fps}
Set frame rate (Hz value, fraction or abbreviation), (default = 25). Set frame rate (Hz value, fraction or abbreviation), (default = 25).
@item -s @var{size} @item -s @var{size}
...@@ -552,11 +567,6 @@ Intra_dc_precision. ...@@ -552,11 +567,6 @@ Intra_dc_precision.
Force video tag/fourcc. Force video tag/fourcc.
@item -qphist @item -qphist
Show QP histogram. Show QP histogram.
@item -vbsf @var{bitstream_filter}
Bitstream filters available are "dump_extra", "remove_extra", "noise", "h264_mp4toannexb", "imxdump", "mjpegadump", "mjpeg2jpeg".
@example
avconv -i h264.mp4 -c:v copy -vbsf h264_mp4toannexb -an out.h264
@end example
@item -force_key_frames @var{time}[,@var{time}...] @item -force_key_frames @var{time}[,@var{time}...]
Force key frames at the specified timestamps, more precisely at the first Force key frames at the specified timestamps, more precisely at the first
frames after each specified time. frames after each specified time.
...@@ -569,7 +579,7 @@ The timestamps must be specified in ascending order. ...@@ -569,7 +579,7 @@ The timestamps must be specified in ascending order.
@table @option @table @option
@item -aframes @var{number} @item -aframes @var{number}
Set the number of audio frames to record. Set the number of audio frames to record. This is an alias for @code{-frames:a}.
@item -ar @var{freq} @item -ar @var{freq}
Set the audio sampling frequency. For output streams it is set by Set the audio sampling frequency. For output streams it is set by
default to the frequency of the corresponding input stream. For input default to the frequency of the corresponding input stream. For input
...@@ -617,8 +627,6 @@ Voice Over ...@@ -617,8 +627,6 @@ Voice Over
@item ka @item ka
Karaoke Karaoke
@end table @end table
@item -absf @var{bitstream_filter}
Bitstream filters available are "dump_extra", "remove_extra", "noise", "mp3comp", "mp3decomp".
@end table @end table
@section Subtitle options: @section Subtitle options:
...@@ -630,11 +638,6 @@ Set the subtitle codec. This is an alias for @code{-codec:s}. ...@@ -630,11 +638,6 @@ Set the subtitle codec. This is an alias for @code{-codec:s}.
Set the ISO 639 language code (3 letters) of the current subtitle stream. Set the ISO 639 language code (3 letters) of the current subtitle stream.
@item -sn @item -sn
Disable subtitle recording. Disable subtitle recording.
@item -sbsf @var{bitstream_filter}
Bitstream filters available are "mov2textsub", "text2movsub".
@example
avconv -i file.mov -an -vn -sbsf mov2textsub -c:s copy -f rawvideo sub.txt
@end example
@end table @end table
@section Audio/Video grab options @section Audio/Video grab options
...@@ -797,6 +800,17 @@ an output mpegts file: ...@@ -797,6 +800,17 @@ an output mpegts file:
@example @example
avconv -i infile -streamid 0:33 -streamid 1:36 out.ts avconv -i infile -streamid 0:33 -streamid 1:36 out.ts
@end example @end example
@item -bsf[:@var{stream_specifier}] @var{bitstream_filters}
Set bitstream filters for matching streams. @var{bistream_filters} is
a comma-separated list of bitstream filters. Use the @code{-bsfs} option
to get the list of bitstream filters.
@example
avconv -i h264.mp4 -c:v copy -vbsf h264_mp4toannexb -an out.h264
@end example
@example
avconv -i file.mov -an -vn -sbsf mov2textsub -c:s copy -f rawvideo sub.txt
@end example
@end table @end table
@c man end OPTIONS @c man end OPTIONS
......
This diff is collapsed.
...@@ -2167,7 +2167,7 @@ static av_cold int validate_options(AC3EncodeContext *s) ...@@ -2167,7 +2167,7 @@ static av_cold int validate_options(AC3EncodeContext *s)
(s->channel_mode == AC3_CHMODE_STEREO); (s->channel_mode == AC3_CHMODE_STEREO);
s->cpl_enabled = s->options.channel_coupling && s->cpl_enabled = s->options.channel_coupling &&
s->channel_mode >= AC3_CHMODE_STEREO && !s->fixed_point; s->channel_mode >= AC3_CHMODE_STEREO;
return 0; return 0;
} }
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#define MAC_COEF(d,a,b) ((d)+=(a)*(b)) #define MAC_COEF(d,a,b) ((d)+=(a)*(b))
#define COEF_MIN (-16777215.0/16777216.0) #define COEF_MIN (-16777215.0/16777216.0)
#define COEF_MAX ( 16777215.0/16777216.0) #define COEF_MAX ( 16777215.0/16777216.0)
#define NEW_CPL_COORD_THRESHOLD 0.03
typedef float SampleType; typedef float SampleType;
typedef float CoefType; typedef float CoefType;
typedef float CoefSumType; typedef float CoefSumType;
...@@ -60,6 +61,7 @@ typedef float CoefSumType; ...@@ -60,6 +61,7 @@ typedef float CoefSumType;
#define MAC_COEF(d,a,b) MAC64(d,a,b) #define MAC_COEF(d,a,b) MAC64(d,a,b)
#define COEF_MIN -16777215 #define COEF_MIN -16777215
#define COEF_MAX 16777215 #define COEF_MAX 16777215
#define NEW_CPL_COORD_THRESHOLD 503317
typedef int16_t SampleType; typedef int16_t SampleType;
typedef int32_t CoefType; typedef int32_t CoefType;
typedef int64_t CoefSumType; typedef int64_t CoefSumType;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#define CONFIG_FFT_FLOAT 0 #define CONFIG_FFT_FLOAT 0
#undef CONFIG_AC3ENC_FLOAT #undef CONFIG_AC3ENC_FLOAT
#include "ac3enc.h" #include "ac3enc.h"
#include "eac3enc.h"
#define AC3ENC_TYPE AC3ENC_TYPE_AC3_FIXED #define AC3ENC_TYPE AC3ENC_TYPE_AC3_FIXED
#include "ac3enc_opts_template.c" #include "ac3enc_opts_template.c"
...@@ -112,6 +113,22 @@ static void clip_coefficients(DSPContext *dsp, int32_t *coef, unsigned int len) ...@@ -112,6 +113,22 @@ static void clip_coefficients(DSPContext *dsp, int32_t *coef, unsigned int len)
} }
/**
* Calculate a single coupling coordinate.
*/
static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl)
{
if (energy_cpl <= COEF_MAX) {
return 1048576;
} else {
uint64_t coord = energy_ch / (energy_cpl >> 24);
uint32_t coord32 = FFMIN(coord, 1073741824);
coord32 = ff_sqrt(coord32) << 9;
return FFMIN(coord32, COEF_MAX);
}
}
static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx) static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx)
{ {
AC3EncodeContext *s = avctx->priv_data; AC3EncodeContext *s = avctx->priv_data;
......
...@@ -104,9 +104,10 @@ static int normalize_samples(AC3EncodeContext *s) ...@@ -104,9 +104,10 @@ static int normalize_samples(AC3EncodeContext *s)
static void scale_coefficients(AC3EncodeContext *s) static void scale_coefficients(AC3EncodeContext *s)
{ {
int chan_size = AC3_MAX_COEFS * s->num_blocks; int chan_size = AC3_MAX_COEFS * s->num_blocks;
s->ac3dsp.float_to_fixed24(s->fixed_coef_buffer + chan_size, int cpl = s->cpl_on;
s->mdct_coef_buffer + chan_size, s->ac3dsp.float_to_fixed24(s->fixed_coef_buffer + (chan_size * !cpl),
chan_size * s->channels); s->mdct_coef_buffer + (chan_size * !cpl),
chan_size * (s->channels + cpl));
} }
...@@ -119,6 +120,18 @@ static void clip_coefficients(DSPContext *dsp, float *coef, unsigned int len) ...@@ -119,6 +120,18 @@ static void clip_coefficients(DSPContext *dsp, float *coef, unsigned int len)
} }
/**
* Calculate a single coupling coordinate.
*/
static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl)
{
float coord = 0.125;
if (energy_cpl > 0)
coord *= sqrtf(energy_ch / energy_cpl);
return FFMIN(coord, COEF_MAX);
}
#if CONFIG_AC3_ENCODER #if CONFIG_AC3_ENCODER
AVCodec ff_ac3_encoder = { AVCodec ff_ac3_encoder = {
.name = "ac3", .name = "ac3",
......
...@@ -72,11 +72,9 @@ static const AVOption eac3_options[] = { ...@@ -72,11 +72,9 @@ static const AVOption eac3_options[] = {
{"hdcd", "HDCD", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_ADCONV_HDCD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"}, {"hdcd", "HDCD", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_ADCONV_HDCD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
/* Other Encoding Options */ /* Other Encoding Options */
{"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_ON }, AC3ENC_OPT_OFF, AC3ENC_OPT_ON, AC3ENC_PARAM}, {"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_ON }, AC3ENC_OPT_OFF, AC3ENC_OPT_ON, AC3ENC_PARAM},
#if AC3ENC_TYPE != AC3ENC_TYPE_AC3_FIXED
{"channel_coupling", "Channel Coupling", OFFSET(channel_coupling), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, AC3ENC_OPT_ON, AC3ENC_PARAM, "channel_coupling"}, {"channel_coupling", "Channel Coupling", OFFSET(channel_coupling), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, AC3ENC_OPT_ON, AC3ENC_PARAM, "channel_coupling"},
{"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "channel_coupling"}, {"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "channel_coupling"},
{"cpl_start_band", "Coupling Start Band", OFFSET(cpl_start), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, 15, AC3ENC_PARAM, "cpl_start_band"}, {"cpl_start_band", "Coupling Start Band", OFFSET(cpl_start), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, 15, AC3ENC_PARAM, "cpl_start_band"},
{"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"}, {"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"},
#endif
{NULL} {NULL}
}; };
...@@ -41,6 +41,8 @@ static int normalize_samples(AC3EncodeContext *s); ...@@ -41,6 +41,8 @@ static int normalize_samples(AC3EncodeContext *s);
static void clip_coefficients(DSPContext *dsp, CoefType *coef, unsigned int len); static void clip_coefficients(DSPContext *dsp, CoefType *coef, unsigned int len);
static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl);
int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s) int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s)
{ {
...@@ -118,32 +120,25 @@ static void apply_mdct(AC3EncodeContext *s) ...@@ -118,32 +120,25 @@ static void apply_mdct(AC3EncodeContext *s)
} }
/**
* Calculate a single coupling coordinate.
*/
static inline float calc_cpl_coord(float energy_ch, float energy_cpl)
{
float coord = 0.125;
if (energy_cpl > 0)
coord *= sqrtf(energy_ch / energy_cpl);
return FFMIN(coord, COEF_MAX);
}
/** /**
* Calculate coupling channel and coupling coordinates. * Calculate coupling channel and coupling coordinates.
*/ */
static void apply_channel_coupling(AC3EncodeContext *s) static void apply_channel_coupling(AC3EncodeContext *s)
{ {
LOCAL_ALIGNED_16(CoefType, cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
#if CONFIG_AC3ENC_FLOAT #if CONFIG_AC3ENC_FLOAT
LOCAL_ALIGNED_16(float, cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
LOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]); LOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
#else
int32_t (*fixed_cpl_coords)[AC3_MAX_CHANNELS][16] = cpl_coords;
#endif
int blk, ch, bnd, i, j; int blk, ch, bnd, i, j;
CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}}; CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}};
int cpl_start, num_cpl_coefs; int cpl_start, num_cpl_coefs;
memset(cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords)); memset(cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
memset(fixed_cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*fixed_cpl_coords)); #if CONFIG_AC3ENC_FLOAT
memset(fixed_cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
#endif
/* align start to 16-byte boundary. align length to multiple of 32. /* align start to 16-byte boundary. align length to multiple of 32.
note: coupling start bin % 4 will always be 1 */ note: coupling start bin % 4 will always be 1 */
...@@ -168,10 +163,6 @@ static void apply_channel_coupling(AC3EncodeContext *s) ...@@ -168,10 +163,6 @@ static void apply_channel_coupling(AC3EncodeContext *s)
/* coefficients must be clipped in order to be encoded */ /* coefficients must be clipped in order to be encoded */
clip_coefficients(&s->dsp, cpl_coef, num_cpl_coefs); clip_coefficients(&s->dsp, cpl_coef, num_cpl_coefs);
/* scale coupling coefficients from float to 24-bit fixed-point */
s->ac3dsp.float_to_fixed24(&block->fixed_coef[CPL_CH][cpl_start],
cpl_coef, num_cpl_coefs);
} }
/* calculate energy in each band in coupling channel and each fbw channel */ /* calculate energy in each band in coupling channel and each fbw channel */
...@@ -235,11 +226,11 @@ static void apply_channel_coupling(AC3EncodeContext *s) ...@@ -235,11 +226,11 @@ static void apply_channel_coupling(AC3EncodeContext *s)
} else { } else {
CoefSumType coord_diff = 0; CoefSumType coord_diff = 0;
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
coord_diff += fabs(cpl_coords[blk-1][ch][bnd] - coord_diff += FFABS(cpl_coords[blk-1][ch][bnd] -
cpl_coords[blk ][ch][bnd]); cpl_coords[blk ][ch][bnd]);
} }
coord_diff /= s->num_cpl_bands; coord_diff /= s->num_cpl_bands;
if (coord_diff > 0.03) if (coord_diff > NEW_CPL_COORD_THRESHOLD)
block->new_cpl_coords[ch] = 1; block->new_cpl_coords[ch] = 1;
} }
} }
...@@ -286,9 +277,11 @@ static void apply_channel_coupling(AC3EncodeContext *s) ...@@ -286,9 +277,11 @@ static void apply_channel_coupling(AC3EncodeContext *s)
if (!block->cpl_in_use) if (!block->cpl_in_use)
continue; continue;
#if CONFIG_AC3ENC_FLOAT
s->ac3dsp.float_to_fixed24(fixed_cpl_coords[blk][1], s->ac3dsp.float_to_fixed24(fixed_cpl_coords[blk][1],
cpl_coords[blk][1], cpl_coords[blk][1],
s->fbw_channels * 16); s->fbw_channels * 16);
#endif
s->ac3dsp.extract_exponents(block->cpl_coord_exp[1], s->ac3dsp.extract_exponents(block->cpl_coord_exp[1],
fixed_cpl_coords[blk][1], fixed_cpl_coords[blk][1],
s->fbw_channels * 16); s->fbw_channels * 16);
...@@ -332,7 +325,6 @@ static void apply_channel_coupling(AC3EncodeContext *s) ...@@ -332,7 +325,6 @@ static void apply_channel_coupling(AC3EncodeContext *s)
if (CONFIG_EAC3_ENCODER && s->eac3) if (CONFIG_EAC3_ENCODER && s->eac3)
ff_eac3_set_cpl_states(s); ff_eac3_set_cpl_states(s);
#endif /* CONFIG_AC3ENC_FLOAT */
} }
...@@ -352,11 +344,6 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s) ...@@ -352,11 +344,6 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
block = &s->blocks[blk]; block = &s->blocks[blk];
block->new_rematrixing_strategy = !blk; block->new_rematrixing_strategy = !blk;
if (!s->rematrixing_enabled) {
block0 = block;
continue;
}
block->num_rematrixing_bands = 4; block->num_rematrixing_bands = 4;
if (block->cpl_in_use) { if (block->cpl_in_use) {
block->num_rematrixing_bands -= (s->start_freq[CPL_CH] <= 61); block->num_rematrixing_bands -= (s->start_freq[CPL_CH] <= 61);
...@@ -366,6 +353,11 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s) ...@@ -366,6 +353,11 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
} }
nb_coefs = FFMIN(block->end_freq[1], block->end_freq[2]); nb_coefs = FFMIN(block->end_freq[1], block->end_freq[2]);
if (!s->rematrixing_enabled) {
block0 = block;
continue;
}
for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++) { for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++) {
/* calculate calculate sum of squared coeffs for one band in one block */ /* calculate calculate sum of squared coeffs for one band in one block */
int start = ff_ac3_rematrix_band_tab[bnd]; int start = ff_ac3_rematrix_band_tab[bnd];
......
...@@ -1949,7 +1949,7 @@ static int slice_decode_thread(AVCodecContext *c, void *arg){ ...@@ -1949,7 +1949,7 @@ static int slice_decode_thread(AVCodecContext *c, void *arg){
//ret, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, s->start_mb_y, s->end_mb_y, s->error_count); //ret, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, s->start_mb_y, s->end_mb_y, s->error_count);
if(ret < 0){ if(ret < 0){
if (c->error_recognition >= FF_ER_EXPLODE) if (c->error_recognition >= FF_ER_EXPLODE)
return AVERROR_INVALIDDATA; return ret;
if(s->resync_mb_x>=0 && s->resync_mb_y>=0) if(s->resync_mb_x>=0 && s->resync_mb_y>=0)
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR); ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
}else{ }else{
...@@ -2303,10 +2303,11 @@ static int mpeg_decode_frame(AVCodecContext *avctx, ...@@ -2303,10 +2303,11 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
s->slice_count= 0; s->slice_count= 0;
if(avctx->extradata && !avctx->frame_number && if(avctx->extradata && !avctx->frame_number) {
decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size) < 0 && int ret = decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size);
avctx->error_recognition >= FF_ER_EXPLODE) if (ret < 0 && avctx->error_recognition >= FF_ER_EXPLODE)
return AVERROR_INVALIDDATA; return ret;
}
return decode_chunks(avctx, picture, data_size, buf, buf_size); return decode_chunks(avctx, picture, data_size, buf, buf_size);
} }
...@@ -2381,17 +2382,17 @@ static int decode_chunks(AVCodecContext *avctx, ...@@ -2381,17 +2382,17 @@ static int decode_chunks(AVCodecContext *avctx,
s->slice_count = 0; s->slice_count = 0;
} }
if(last_code == 0 || last_code == SLICE_MIN_START_CODE){ if(last_code == 0 || last_code == SLICE_MIN_START_CODE){
if(mpeg_decode_postinit(avctx) < 0){ ret = mpeg_decode_postinit(avctx);
av_log(avctx, AV_LOG_ERROR, "mpeg_decode_postinit() failure\n"); if(ret < 0){
return -1; av_log(avctx, AV_LOG_ERROR, "mpeg_decode_postinit() failure\n");
} return ret;
}
/* we have a complete image: we try to decompress it */ /* we have a complete image: we try to decompress it */
if(mpeg1_decode_picture(avctx, if (mpeg1_decode_picture(avctx, buf_ptr, input_size) < 0)
buf_ptr, input_size) < 0) s2->pict_type=0;
s2->pict_type=0;
s2->first_slice = 1; s2->first_slice = 1;
last_code= PICTURE_START_CODE; last_code= PICTURE_START_CODE;
}else{ }else{
av_log(avctx, AV_LOG_ERROR, "ignoring pic after %X\n", last_code); av_log(avctx, AV_LOG_ERROR, "ignoring pic after %X\n", last_code);
if (avctx->error_recognition >= FF_ER_EXPLODE) if (avctx->error_recognition >= FF_ER_EXPLODE)
...@@ -2437,9 +2438,8 @@ static int decode_chunks(AVCodecContext *avctx, ...@@ -2437,9 +2438,8 @@ static int decode_chunks(AVCodecContext *avctx,
break; break;
case GOP_START_CODE: case GOP_START_CODE:
if(last_code == 0){ if(last_code == 0){
s2->first_field=0; s2->first_field=0;
mpeg_decode_gop(avctx, mpeg_decode_gop(avctx, buf_ptr, input_size);
buf_ptr, input_size);
s->sync=1; s->sync=1;
}else{ }else{
av_log(avctx, AV_LOG_ERROR, "ignoring GOP_START_CODE after %X\n", last_code); av_log(avctx, AV_LOG_ERROR, "ignoring GOP_START_CODE after %X\n", last_code);
...@@ -2501,9 +2501,7 @@ static int decode_chunks(AVCodecContext *avctx, ...@@ -2501,9 +2501,7 @@ static int decode_chunks(AVCodecContext *avctx,
} }
if(!s2->current_picture_ptr){ if(!s2->current_picture_ptr){
av_log(avctx, AV_LOG_ERROR, "current_picture not initialized\n"); av_log(avctx, AV_LOG_ERROR, "current_picture not initialized\n");
if (avctx->error_recognition >= FF_ER_EXPLODE) return AVERROR_INVALIDDATA;
return AVERROR_INVALIDDATA;
return -1;
} }
if (uses_vdpau(avctx)) { if (uses_vdpau(avctx)) {
...@@ -2533,7 +2531,7 @@ static int decode_chunks(AVCodecContext *avctx, ...@@ -2533,7 +2531,7 @@ static int decode_chunks(AVCodecContext *avctx,
if(ret < 0){ if(ret < 0){
if (avctx->error_recognition >= FF_ER_EXPLODE) if (avctx->error_recognition >= FF_ER_EXPLODE)
return AVERROR_INVALIDDATA; return ret;
if(s2->resync_mb_x>=0 && s2->resync_mb_y>=0) if(s2->resync_mb_x>=0 && s2->resync_mb_y>=0)
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR); ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
}else{ }else{
......
...@@ -470,6 +470,7 @@ static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) ...@@ -470,6 +470,7 @@ static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S)
static void wv_reset_saved_context(WavpackFrameContext *s) static void wv_reset_saved_context(WavpackFrameContext *s)
{ {
s->pos = 0; s->pos = 0;
s->samples_left = 0;
s->sc.crc = s->extra_sc.crc = 0xFFFFFFFF; s->sc.crc = s->extra_sc.crc = 0xFFFFFFFF;
} }
...@@ -582,6 +583,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo ...@@ -582,6 +583,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo
s->samples_left -= count; s->samples_left -= count;
if(!s->samples_left){ if(!s->samples_left){
wv_reset_saved_context(s);
if(crc != s->CRC){ if(crc != s->CRC){
av_log(s->avctx, AV_LOG_ERROR, "CRC error\n"); av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
return -1; return -1;
...@@ -590,7 +592,6 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo ...@@ -590,7 +592,6 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo
av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n"); av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
return -1; return -1;
} }
wv_reset_saved_context(s);
}else{ }else{
s->pos = pos; s->pos = pos;
s->sc.crc = crc; s->sc.crc = crc;
...@@ -660,6 +661,7 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void ...@@ -660,6 +661,7 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void
s->samples_left -= count; s->samples_left -= count;
if(!s->samples_left){ if(!s->samples_left){
wv_reset_saved_context(s);
if(crc != s->CRC){ if(crc != s->CRC){
av_log(s->avctx, AV_LOG_ERROR, "CRC error\n"); av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
return -1; return -1;
...@@ -668,7 +670,6 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void ...@@ -668,7 +670,6 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void
av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n"); av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
return -1; return -1;
} }
wv_reset_saved_context(s);
}else{ }else{
s->pos = pos; s->pos = pos;
s->sc.crc = crc; s->sc.crc = crc;
...@@ -779,7 +780,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, ...@@ -779,7 +780,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
s->samples = AV_RL32(buf); buf += 4; s->samples = AV_RL32(buf); buf += 4;
if(!s->samples){ if(!s->samples){
*data_size = 0; *data_size = 0;
return buf_size; return 0;
} }
}else{ }else{
s->samples = wc->samples; s->samples = wc->samples;
...@@ -1195,7 +1196,7 @@ static void wavpack_decode_flush(AVCodecContext *avctx) ...@@ -1195,7 +1196,7 @@ static void wavpack_decode_flush(AVCodecContext *avctx)
int i; int i;
for (i = 0; i < s->fdec_num; i++) for (i = 0; i < s->fdec_num; i++)
s->fdec[i]->samples_left = 0; wv_reset_saved_context(s->fdec[i]);
} }
AVCodec ff_wavpack_decoder = { AVCodec ff_wavpack_decoder = {
......
...@@ -16,7 +16,7 @@ cmp=${6:-diff} ...@@ -16,7 +16,7 @@ cmp=${6:-diff}
ref=${7:-"${base}/ref/fate/${test}"} ref=${7:-"${base}/ref/fate/${test}"}
fuzz=$8 fuzz=$8
threads=${9:-1} threads=${9:-1}
thread_type=${10:-3} thread_type=${10:-frame+slice}
tool=${11} tool=${11}
outdir="tests/data/fate" outdir="tests/data/fate"
......
...@@ -374,6 +374,6 @@ fate-h264-conformance-sva_fm1_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conf ...@@ -374,6 +374,6 @@ fate-h264-conformance-sva_fm1_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conf
fate-h264-conformance-sva_nl1_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_NL1_B.264 fate-h264-conformance-sva_nl1_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_NL1_B.264
fate-h264-conformance-sva_nl2_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_NL2_E.264 fate-h264-conformance-sva_nl2_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_NL2_E.264
fate-h264-interlace-crop: CMD = framecrc -vsync 0 -vframes 3 -i $(SAMPLES)/h264/interlaced_crop.mp4 fate-h264-interlace-crop: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264/interlaced_crop.mp4 -vframes 3
fate-h264-lossless: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264/lossless.h264 fate-h264-lossless: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264/lossless.h264
fate-h264-extreme-plane-pred: CMD = framemd5 -strict 1 -vsync 0 -i $(SAMPLES)/h264/extreme-plane-pred.h264 fate-h264-extreme-plane-pred: CMD = framemd5 -strict 1 -vsync 0 -i $(SAMPLES)/h264/extreme-plane-pred.h264
0f14801e166819dd4a58981aea36e08b *./tests/data/acodec/ac3.rm e7fa185030a56d9db8663ad9e38c6c94 *./tests/data/acodec/ac3.rm
98751 ./tests/data/acodec/ac3.rm 98751 ./tests/data/acodec/ac3.rm
...@@ -5,35 +5,40 @@ ret:-1 st:-1 flags:1 ts: 1.894167 ...@@ -5,35 +5,40 @@ ret:-1 st:-1 flags:1 ts: 1.894167
ret:-1 st: 0 flags:0 ts: 0.788000 ret:-1 st: 0 flags:0 ts: 0.788000
ret: 0 st: 0 flags:1 ts:-0.317000 ret: 0 st: 0 flags:1 ts:-0.317000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret: 0 st:-1 flags:0 ts: 2.576668 ret:-1 st:-1 flags:0 ts: 2.576668
ret: 0 st: 0 flags:1 dts: 2.577000 pts: 2.577000 pos: 42397 size: 558
ret:-1 st:-1 flags:1 ts: 1.470835 ret:-1 st:-1 flags:1 ts: 1.470835
ret:-1 st: 0 flags:0 ts: 0.365000 ret:-1 st: 0 flags:0 ts: 0.365000
ret: 0 st: 0 flags:1 ts:-0.741000 ret: 0 st: 0 flags:1 ts:-0.741000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret: 0 st:-1 flags:0 ts: 2.153336 ret:-1 st:-1 flags:0 ts: 2.153336
ret: 0 st: 0 flags:1 dts: 2.159000 pts: 2.159000 pos: 35567 size: 556
ret:-1 st:-1 flags:1 ts: 1.047503 ret:-1 st:-1 flags:1 ts: 1.047503
ret: 0 st: 0 flags:0 ts:-0.058000 ret: 0 st: 0 flags:0 ts:-0.058000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret:-1 st: 0 flags:1 ts: 2.836000 ret:-1 st: 0 flags:1 ts: 2.836000
ret:-1 st:-1 flags:0 ts: 1.730004 ret: 0 st:-1 flags:0 ts: 1.730004
ret:-1 st:-1 flags:1 ts: 0.624171 ret: 0 st: 0 flags:1 dts:8589.800000 pts:8589.800000 pos: 65950 size: 32801
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.256000 pts: 0.256000 pos: 65337 size: 400
ret: 0 st: 0 flags:0 ts:-0.482000 ret: 0 st: 0 flags:0 ts:-0.482000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret: 0 st: 0 flags:1 ts: 2.413000 ret:-1 st: 0 flags:1 ts: 2.413000
ret: 0 st: 0 flags:1 dts: 2.368000 pts: 2.368000 pos: 38981 size: 558 ret: 0 st:-1 flags:0 ts: 1.306672
ret:-1 st:-1 flags:0 ts: 1.306672 ret: 0 st: 0 flags:1 dts:8589.800000 pts:8589.800000 pos: 65950 size: 32801
ret:-1 st:-1 flags:1 ts: 0.200839 ret: 0 st:-1 flags:1 ts: 0.200839
ret: 0 st: 0 flags:1 dts: 0.034000 pts: 0.034000 pos: 839 size: 558
ret: 0 st: 0 flags:0 ts:-0.905000 ret: 0 st: 0 flags:0 ts:-0.905000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret:-1 st: 0 flags:1 ts: 1.989000 ret: 0 st: 0 flags:1 ts: 1.989000
ret:-1 st:-1 flags:0 ts: 0.883340 ret: 0 st: 0 flags:1 dts: 0.256000 pts: 0.256000 pos: 65337 size: 400
ret: 0 st:-1 flags:0 ts: 0.883340
ret: 0 st: 0 flags:1 dts: 3.378000 pts: 3.378000 pos: 55491 size: 558
ret: 0 st:-1 flags:1 ts:-0.222493 ret: 0 st:-1 flags:1 ts:-0.222493
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret: 0 st: 0 flags:0 ts: 2.672000 ret: 0 st: 0 flags:0 ts: 2.672000
ret: 0 st: 0 flags:1 dts: 2.821000 pts: 2.821000 pos: 46383 size: 556 ret: 0 st: 0 flags:1 dts: 3.378000 pts: 3.378000 pos: 55491 size: 558
ret:-1 st: 0 flags:1 ts: 1.566000 ret: 0 st: 0 flags:1 ts: 1.566000
ret:-1 st:-1 flags:0 ts: 0.460008 ret: 0 st: 0 flags:1 dts: 0.256000 pts: 0.256000 pos: 65337 size: 400
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 3.378000 pts: 3.378000 pos: 55491 size: 558
ret: 0 st:-1 flags:1 ts:-0.645825 ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment