Compare commits
161 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7873dfcca | |||
| 9790ed63fc | |||
| 0e3a1d60d3 | |||
| a45a665991 | |||
| c2c922460a | |||
| d192ff0ece | |||
| 4d1346d46a | |||
| 66a9c50d42 | |||
| 3065919b65 | |||
| f1feb7e388 | |||
| ccbcb17960 | |||
| a71b4209c2 | |||
| 60ed439334 | |||
| 76838fb171 | |||
| e3b6e23a0f | |||
| 6a51bd7360 | |||
| 2572372f90 | |||
| 2a543e58ec | |||
| aaf6ddfa4d | |||
| 2b45eab4c9 | |||
| d89e5b20f2 | |||
| ac182d6d8b | |||
| 9cde200ba7 | |||
| df208d6ab9 | |||
| 4eb0b6c590 | |||
| 90a384cde1 | |||
| af109ff125 | |||
| ec2ce83913 | |||
| 1d91251370 | |||
| 861e453996 | |||
| 5228655438 | |||
| d2e3afbbd1 | |||
| c33770e74b | |||
| 9c358c6e3b | |||
| 26d72b3df0 | |||
| 6729193886 | |||
| 9d8e231459 | |||
| 15871a90aa | |||
| 37f854f5b9 | |||
| 9c83914a1f | |||
| 861732246f | |||
| 46b64d9818 | |||
| c5085a0301 | |||
| 4c9c76af85 | |||
| e4f9a5efa1 | |||
| 61e5001b26 | |||
| 380587cc34 | |||
| 998b5ac3a0 | |||
| b8f6069bf3 | |||
| 2b5b21dbac | |||
| 4201c74545 | |||
| 946810d1da | |||
| f3802aa325 | |||
| c5606c04cf | |||
| 39256e54d1 | |||
| 992cdbc56a | |||
| e8bb67c2a9 | |||
| 60e2f9bf8b | |||
| bdba204bd0 | |||
| be4d4a61b5 | |||
| 83f58778cb | |||
| c5a2c26c55 | |||
| 03c5ccb4ee | |||
| 172a5cab87 | |||
| 8d6de87709 | |||
| af04f0d1ce | |||
| 116b959565 | |||
| 7269ab10c5 | |||
| caeed48982 | |||
| 353f79defc | |||
| 92d336670f | |||
| 3c880d2765 | |||
| 63dcf7c77c | |||
| 610a064607 | |||
| 65c915d0c3 | |||
| 8c8db86c0d | |||
| 44799d269f | |||
| 3c8a12be2f | |||
| 0c5f166e6f | |||
| 5a45c644e8 | |||
| 02d46127f5 | |||
| 2e99fab15c | |||
| 9098da0329 | |||
| db53b2b2c0 | |||
| c7a854af19 | |||
| 3e73bea05f | |||
| 3712b398e9 | |||
| 4362a222e2 | |||
| a9753049b5 | |||
| 910fd77967 | |||
| d87ac93bca | |||
| 96603d5753 | |||
| c7c724056e | |||
| d3139c9733 | |||
| 0909b8acf8 | |||
| 2368d08e70 | |||
| ea7ccf3748 | |||
| 846a9c67ff | |||
| c8d363a359 | |||
| d0d441b350 | |||
| 6341a7006d | |||
| 7034e808f6 | |||
| ce5d9a2b4b | |||
| aa672f5e6a | |||
| b959e6393e | |||
| 69f99f80d1 | |||
| e7b7e69416 | |||
| 9330bcff9b | |||
| 9fb364babd | |||
| d79419d0f9 | |||
| ebc490e744 | |||
| ab1c7113f9 | |||
| 10a30e4de5 | |||
| 9368b91834 | |||
| f22e88c177 | |||
| e266fcf083 | |||
| c9b961748f | |||
| a94f367424 | |||
| 18eac12c6d | |||
| 4cc18ee5da | |||
| f8985cb9d9 | |||
| 656770e2aa | |||
| 4a28a3ddc4 | |||
| f91ef98c9d | |||
| a644272a4a | |||
| 325feb8e0d | |||
| 8c6a976fee | |||
| ac38860ec9 | |||
| d0e0329e9d | |||
| 9ca79d2849 | |||
| c5a2a65e1e | |||
| a8ed3685e1 | |||
| 32262ca7d7 | |||
| 5f56e495ae | |||
| fedbba5ea0 | |||
| d35916f6ea | |||
| 94e2673f4e | |||
| 23ae7bfb4e | |||
| 9e8464e81b | |||
| c9a8dfa5ae | |||
| e6299a4cf9 | |||
| ee3822af63 | |||
| fc5261c219 | |||
| 30a94f1159 | |||
| 9d83cff1f1 | |||
| 756cd1a305 | |||
| 83dc8f044d | |||
| 2c5c6affb1 | |||
| f4e051680e | |||
| 2f4b781e4d | |||
| 0d45e821dc | |||
| eda6effcab | |||
| 45900618ae | |||
| 16e49d85b6 | |||
| bfdfeadf11 | |||
| 7ae6229b97 | |||
| 2156d9bd7d | |||
| 0a055cc62e | |||
| c8d43c22db | |||
| d9b7557732 | |||
| 15d7b7d7cc |
+1
-1
@@ -68,7 +68,7 @@ struct SwsContext *sws_opts;
|
||||
AVDictionary *swr_opts;
|
||||
AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||
|
||||
const int this_year = 2013;
|
||||
const int this_year = 2014;
|
||||
|
||||
static FILE *report_file;
|
||||
|
||||
|
||||
@@ -729,6 +729,10 @@ add_ldflags(){
|
||||
append LDFLAGS $($ldflags_filter "$@")
|
||||
}
|
||||
|
||||
add_stripflags(){
|
||||
append ASMSTRIPFLAGS "$@"
|
||||
}
|
||||
|
||||
add_extralibs(){
|
||||
prepend extralibs $($ldflags_filter "$@")
|
||||
}
|
||||
@@ -886,6 +890,20 @@ check_ldflags(){
|
||||
test_ldflags "$@" && add_ldflags "$@"
|
||||
}
|
||||
|
||||
test_stripflags(){
|
||||
log test_stripflags "$@"
|
||||
# call check_cc to get a fresh TMPO
|
||||
check_cc <<EOF
|
||||
int main(void) { return 0; }
|
||||
EOF
|
||||
check_cmd $strip $ASMSTRIPFLAGS "$@" $TMPO
|
||||
}
|
||||
|
||||
check_stripflags(){
|
||||
log check_stripflags "$@"
|
||||
test_stripflags "$@" && add_stripflags "$@"
|
||||
}
|
||||
|
||||
check_header(){
|
||||
log check_header "$@"
|
||||
header=$1
|
||||
@@ -2018,6 +2036,7 @@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
|
||||
|
||||
# parsers
|
||||
h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
|
||||
hevc_parser_select="hevc_decoder"
|
||||
mpeg4video_parser_select="error_resilience mpegvideo"
|
||||
mpegvideo_parser_select="error_resilience mpegvideo"
|
||||
vc1_parser_select="mpegvideo"
|
||||
@@ -4255,7 +4274,7 @@ enabled ladspa && { check_header ladspa.h || die "ERROR: ladspa.h hea
|
||||
enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
|
||||
enabled libaacplus && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus
|
||||
enabled libass && require_pkg_config libass ass/ass.h ass_library_init
|
||||
enabled libbluray && require libbluray libbluray/bluray.h bd_open -lbluray
|
||||
enabled libbluray && require_pkg_config libbluray libbluray/bluray.h bd_open
|
||||
enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 &&
|
||||
{ check_lib celt/celt.h celt_decoder_create_custom -lcelt0 ||
|
||||
die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
|
||||
@@ -4460,6 +4479,10 @@ check_ldflags -Wl,--warn-common
|
||||
check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
|
||||
test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
|
||||
|
||||
# add some strip flags
|
||||
# -wN '..@*' is more selective than -x, but not available everywhere.
|
||||
check_stripflags -wN \'..@*\' || check_stripflags -x
|
||||
|
||||
enabled xmm_clobber_test &&
|
||||
check_ldflags -Wl,--wrap,avcodec_open2 \
|
||||
-Wl,--wrap,avcodec_decode_audio4 \
|
||||
@@ -4810,6 +4833,7 @@ LD_PATH=$LD_PATH
|
||||
DLLTOOL=$dlltool
|
||||
LDFLAGS=$LDFLAGS
|
||||
SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
|
||||
ASMSTRIPFLAGS=$ASMSTRIPFLAGS
|
||||
YASMFLAGS=$YASMFLAGS
|
||||
BUILDSUF=$build_suffix
|
||||
PROGSSUF=$progs_suffix
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 2.1.2
|
||||
PROJECT_NUMBER = 2.1.5
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ Select nearest neighbor rescaling algorithm.
|
||||
@item area
|
||||
Select averaging area rescaling algorithm.
|
||||
|
||||
@item bicubiclin
|
||||
@item bicublin
|
||||
Select bicubic scaling algorithm for the luma component, bilinear for
|
||||
chroma components.
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ sigterm_handler(int sig)
|
||||
received_nb_signals++;
|
||||
term_exit();
|
||||
if(received_nb_signals > 3)
|
||||
exit_program(123);
|
||||
exit(123);
|
||||
}
|
||||
|
||||
void term_init(void)
|
||||
|
||||
+6
-3
@@ -42,12 +42,15 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum AVPixelFo
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target);
|
||||
int has_alpha = desc ? desc->nb_components % 2 == 0 : 0;
|
||||
enum AVPixelFormat best= AV_PIX_FMT_NONE;
|
||||
const enum AVPixelFormat mjpeg_formats[] = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
|
||||
const enum AVPixelFormat ljpeg_formats[] = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
|
||||
|
||||
if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
|
||||
if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {
|
||||
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
|
||||
p = mjpeg_formats;
|
||||
} else if (st->codec->codec_id == AV_CODEC_ID_LJPEG) {
|
||||
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
|
||||
p =ljpeg_formats;
|
||||
}
|
||||
}
|
||||
for (; *p != AV_PIX_FMT_NONE; p++) {
|
||||
|
||||
+1
-1
@@ -1728,7 +1728,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
|
||||
/* subtitles: pick first */
|
||||
MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s");
|
||||
if (!o->subtitle_disable && (oc->oformat->subtitle_codec != AV_CODEC_ID_NONE || subtitle_codec_name)) {
|
||||
if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) {
|
||||
for (i = 0; i < nb_input_streams; i++)
|
||||
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||
new_subtitle_stream(o, oc, i);
|
||||
|
||||
@@ -183,6 +183,7 @@ static const char unit_hertz_str[] = "Hz" ;
|
||||
static const char unit_byte_str[] = "byte" ;
|
||||
static const char unit_bit_per_second_str[] = "bit/s";
|
||||
|
||||
static int nb_streams;
|
||||
static uint64_t *nb_streams_packets;
|
||||
static uint64_t *nb_streams_frames;
|
||||
static int *selected_streams;
|
||||
@@ -238,6 +239,7 @@ static char *value_string(char *buf, int buf_size, struct unit_value uv)
|
||||
vald /= pow(10, index * 3);
|
||||
prefix_string = decimal_unit_prefixes[index];
|
||||
}
|
||||
vali = vald;
|
||||
}
|
||||
|
||||
if (show_float || (use_value_prefix && vald != (long long int)vald))
|
||||
@@ -1455,6 +1457,14 @@ static void writer_register_all(void)
|
||||
#define print_section_header(s) writer_print_section_header(w, s)
|
||||
#define print_section_footer(s) writer_print_section_footer(w, s)
|
||||
|
||||
#define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
|
||||
{ \
|
||||
ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
|
||||
if (ret < 0) \
|
||||
goto end; \
|
||||
memset( (ptr) + (cur_n), 0, ((new_n) - (cur_n)) * sizeof(*(ptr)) ); \
|
||||
}
|
||||
|
||||
static inline void show_tags(WriterContext *wctx, AVDictionary *tags, int section_id)
|
||||
{
|
||||
AVDictionaryEntry *tag = NULL;
|
||||
@@ -1673,6 +1683,12 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
|
||||
goto end;
|
||||
}
|
||||
while (!av_read_frame(fmt_ctx, &pkt)) {
|
||||
if (fmt_ctx->nb_streams > nb_streams) {
|
||||
REALLOCZ_ARRAY_STREAM(nb_streams_frames, nb_streams, fmt_ctx->nb_streams);
|
||||
REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, fmt_ctx->nb_streams);
|
||||
REALLOCZ_ARRAY_STREAM(selected_streams, nb_streams, fmt_ctx->nb_streams);
|
||||
nb_streams = fmt_ctx->nb_streams;
|
||||
}
|
||||
if (selected_streams[pkt.stream_index]) {
|
||||
AVRational tb = fmt_ctx->streams[pkt.stream_index]->time_base;
|
||||
|
||||
@@ -2116,9 +2132,10 @@ static int probe_file(WriterContext *wctx, const char *filename)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
nb_streams_frames = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_frames));
|
||||
nb_streams_packets = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_packets));
|
||||
selected_streams = av_calloc(fmt_ctx->nb_streams, sizeof(*selected_streams));
|
||||
nb_streams = fmt_ctx->nb_streams;
|
||||
REALLOCZ_ARRAY_STREAM(nb_streams_frames,0,fmt_ctx->nb_streams);
|
||||
REALLOCZ_ARRAY_STREAM(nb_streams_packets,0,fmt_ctx->nb_streams);
|
||||
REALLOCZ_ARRAY_STREAM(selected_streams,0,fmt_ctx->nb_streams);
|
||||
|
||||
for (i = 0; i < fmt_ctx->nb_streams; i++) {
|
||||
if (stream_specifier) {
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ enum BandType {
|
||||
INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions.
|
||||
};
|
||||
|
||||
#define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
|
||||
#define IS_CODEBOOK_UNSIGNED(x) (((x) - 1) & 10)
|
||||
|
||||
enum ChannelPosition {
|
||||
AAC_CHANNEL_OFF = 0,
|
||||
|
||||
+5
-2
@@ -194,6 +194,9 @@ static int frame_configure_elements(AVCodecContext *avctx)
|
||||
|
||||
/* get output buffer */
|
||||
av_frame_unref(ac->frame);
|
||||
if (!avctx->channels)
|
||||
return 1;
|
||||
|
||||
ac->frame->nb_samples = 2048;
|
||||
if ((ret = ff_get_buffer(avctx, ac->frame, 0)) < 0)
|
||||
return ret;
|
||||
@@ -1402,12 +1405,12 @@ static int decode_pulses(Pulse *pulse, GetBitContext *gb,
|
||||
return -1;
|
||||
pulse->pos[0] = swb_offset[pulse_swb];
|
||||
pulse->pos[0] += get_bits(gb, 5);
|
||||
if (pulse->pos[0] > 1023)
|
||||
if (pulse->pos[0] >= swb_offset[num_swb])
|
||||
return -1;
|
||||
pulse->amp[0] = get_bits(gb, 4);
|
||||
for (i = 1; i < pulse->num_pulse; i++) {
|
||||
pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1];
|
||||
if (pulse->pos[i] > 1023)
|
||||
if (pulse->pos[i] >= swb_offset[num_swb])
|
||||
return -1;
|
||||
pulse->amp[i] = get_bits(gb, 4);
|
||||
}
|
||||
|
||||
+12
-4
@@ -471,9 +471,11 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_
|
||||
* @param[out] coded_samples set to the number of samples as coded in the
|
||||
* packet, or 0 if the codec does not encode the
|
||||
* number of samples in each frame.
|
||||
* @param[out] approx_nb_samples set to non-zero if the number of samples
|
||||
* returned is an approximation.
|
||||
*/
|
||||
static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
int buf_size, int *coded_samples)
|
||||
int buf_size, int *coded_samples, int *approx_nb_samples)
|
||||
{
|
||||
ADPCMDecodeContext *s = avctx->priv_data;
|
||||
int nb_samples = 0;
|
||||
@@ -482,6 +484,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
int header_size;
|
||||
|
||||
*coded_samples = 0;
|
||||
*approx_nb_samples = 0;
|
||||
|
||||
if(ch <= 0)
|
||||
return 0;
|
||||
@@ -552,10 +555,12 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
case AV_CODEC_ID_ADPCM_EA_R2:
|
||||
header_size = 4 + 5 * ch;
|
||||
*coded_samples = bytestream2_get_le32(gb);
|
||||
*approx_nb_samples = 1;
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_EA_R3:
|
||||
header_size = 4 + 5 * ch;
|
||||
*coded_samples = bytestream2_get_be32(gb);
|
||||
*approx_nb_samples = 1;
|
||||
break;
|
||||
}
|
||||
*coded_samples -= *coded_samples % 28;
|
||||
@@ -663,11 +668,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
int16_t **samples_p;
|
||||
int st; /* stereo */
|
||||
int count1, count2;
|
||||
int nb_samples, coded_samples, ret;
|
||||
int nb_samples, coded_samples, approx_nb_samples, ret;
|
||||
GetByteContext gb;
|
||||
|
||||
bytestream2_init(&gb, buf, buf_size);
|
||||
nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples);
|
||||
nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
|
||||
if (nb_samples <= 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -683,7 +688,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
/* use coded_samples when applicable */
|
||||
/* it is always <= nb_samples, so the output buffer will be large enough */
|
||||
if (coded_samples) {
|
||||
if (coded_samples != nb_samples)
|
||||
if (!approx_nb_samples && coded_samples != nb_samples)
|
||||
av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
|
||||
frame->nb_samples = nb_samples = coded_samples;
|
||||
}
|
||||
@@ -917,6 +922,9 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
*samples++ = c->status[0].predictor + c->status[1].predictor;
|
||||
*samples++ = c->status[0].predictor - c->status[1].predictor;
|
||||
}
|
||||
|
||||
if ((bytestream2_tell(&gb) & 1))
|
||||
bytestream2_skip(&gb, 1);
|
||||
break;
|
||||
}
|
||||
case AV_CODEC_ID_ADPCM_IMA_ISS:
|
||||
|
||||
@@ -549,10 +549,11 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
put_bits(&pb, 7, status->step_index);
|
||||
if (avctx->trellis > 0) {
|
||||
uint8_t buf[64];
|
||||
adpcm_compress_trellis(avctx, &samples_p[ch][1], buf, status,
|
||||
adpcm_compress_trellis(avctx, &samples_p[ch][0], buf, status,
|
||||
64, 1);
|
||||
for (i = 0; i < 64; i++)
|
||||
put_bits(&pb, 4, buf[i ^ 1]);
|
||||
status->prev_sample = status->predictor;
|
||||
} else {
|
||||
for (i = 0; i < 64; i += 2) {
|
||||
int t1, t2;
|
||||
|
||||
+7
-4
@@ -150,6 +150,7 @@ typedef struct AICContext {
|
||||
int16_t *data_ptr[NUM_BANDS];
|
||||
|
||||
DECLARE_ALIGNED(16, int16_t, block)[64];
|
||||
DECLARE_ALIGNED(16, uint8_t, quant_matrix)[64];
|
||||
} AICContext;
|
||||
|
||||
static int aic_decode_header(AICContext *ctx, const uint8_t *src, int size)
|
||||
@@ -285,7 +286,7 @@ static void recombine_block_il(int16_t *dst, const uint8_t *scan,
|
||||
}
|
||||
}
|
||||
|
||||
static void unquant_block(int16_t *block, int q)
|
||||
static void unquant_block(int16_t *block, int q, uint8_t *quant_matrix)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -293,7 +294,7 @@ static void unquant_block(int16_t *block, int q)
|
||||
int val = (uint16_t)block[i];
|
||||
int sign = val & 1;
|
||||
|
||||
block[i] = (((val >> 1) ^ -sign) * q * aic_quant_matrix[i] >> 4)
|
||||
block[i] = (((val >> 1) ^ -sign) * q * quant_matrix[i] >> 4)
|
||||
+ sign;
|
||||
}
|
||||
}
|
||||
@@ -334,7 +335,7 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y,
|
||||
else
|
||||
recombine_block_il(ctx->block, ctx->scantable.permutated,
|
||||
&base_y, &ext_y, blk);
|
||||
unquant_block(ctx->block, ctx->quant);
|
||||
unquant_block(ctx->block, ctx->quant, ctx->quant_matrix);
|
||||
ctx->dsp.idct(ctx->block);
|
||||
|
||||
if (!ctx->interlaced) {
|
||||
@@ -352,7 +353,7 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y,
|
||||
for (blk = 0; blk < 2; blk++) {
|
||||
recombine_block(ctx->block, ctx->scantable.permutated,
|
||||
&base_c, &ext_c);
|
||||
unquant_block(ctx->block, ctx->quant);
|
||||
unquant_block(ctx->block, ctx->quant, ctx->quant_matrix);
|
||||
ctx->dsp.idct(ctx->block);
|
||||
ctx->dsp.put_signed_pixels_clamped(ctx->block, C[blk],
|
||||
ctx->frame->linesize[blk + 1]);
|
||||
@@ -430,6 +431,8 @@ static av_cold int aic_decode_init(AVCodecContext *avctx)
|
||||
for (i = 0; i < 64; i++)
|
||||
scan[i] = i;
|
||||
ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, scan);
|
||||
for (i = 0; i < 64; i++)
|
||||
ctx->quant_matrix[ctx->dsp.idct_permutation[i]] = aic_quant_matrix[i];
|
||||
|
||||
ctx->mb_width = FFALIGN(avctx->width, 16) >> 4;
|
||||
ctx->mb_height = FFALIGN(avctx->height, 16) >> 4;
|
||||
|
||||
+6
-2
@@ -280,7 +280,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
GetBitContext gb;
|
||||
uint64_t ht_size;
|
||||
int i, config_offset;
|
||||
MPEG4AudioConfig m4ac;
|
||||
MPEG4AudioConfig m4ac = {0};
|
||||
ALSSpecificConfig *sconf = &ctx->sconf;
|
||||
AVCodecContext *avctx = ctx->avctx;
|
||||
uint32_t als_id, header_size, trailer_size;
|
||||
@@ -688,7 +688,11 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
} else {
|
||||
*bd->opt_order = sconf->max_order;
|
||||
}
|
||||
|
||||
if (*bd->opt_order > bd->block_length) {
|
||||
*bd->opt_order = bd->block_length;
|
||||
av_log(avctx, AV_LOG_ERROR, "Predictor order too large.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
opt_order = *bd->opt_order;
|
||||
|
||||
if (opt_order) {
|
||||
|
||||
+1
-1
@@ -417,7 +417,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
switch(buf[0]) {
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
if (s->nb_args < MAX_NB_ARGS)
|
||||
if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] < 6553)
|
||||
s->args[s->nb_args] = FFMAX(s->args[s->nb_args], 0) * 10 + buf[0] - '0';
|
||||
break;
|
||||
case ';':
|
||||
|
||||
@@ -603,10 +603,14 @@ static void decode_array_0000(APEContext *ctx, GetBitContext *gb,
|
||||
rice->ksum += out[i];
|
||||
}
|
||||
rice->k = av_log2(rice->ksum / 10) + 1;
|
||||
if (rice->k >= 24)
|
||||
return;
|
||||
for (; i < 64; i++) {
|
||||
out[i] = get_rice_ook(&ctx->gb, rice->k);
|
||||
rice->ksum += out[i];
|
||||
rice->k = av_log2(rice->ksum / ((i + 1) * 2)) + 1;
|
||||
if (rice->k >= 24)
|
||||
return;
|
||||
}
|
||||
ksummax = 1 << rice->k + 7;
|
||||
ksummin = rice->k ? (1 << rice->k + 6) : 0;
|
||||
|
||||
@@ -214,6 +214,7 @@ typedef struct AVSContext {
|
||||
int luma_scan[4];
|
||||
int qp;
|
||||
int qp_fixed;
|
||||
int pic_qp_fixed;
|
||||
int cbp;
|
||||
ScanTable scantable;
|
||||
|
||||
|
||||
@@ -900,7 +900,7 @@ static inline int decode_slice_header(AVSContext *h, GetBitContext *gb)
|
||||
|
||||
/* mark top macroblocks as unavailable */
|
||||
h->flags &= ~(B_AVAIL | C_AVAIL);
|
||||
if ((h->mby == 0) && (!h->qp_fixed)) {
|
||||
if (!h->pic_qp_fixed) {
|
||||
h->qp_fixed = get_bits1(gb);
|
||||
h->qp = get_bits(gb, 6);
|
||||
}
|
||||
@@ -1023,6 +1023,7 @@ static int decode_pic(AVSContext *h)
|
||||
skip_bits1(&h->gb); //advanced_pred_mode_disable
|
||||
skip_bits1(&h->gb); //top_field_first
|
||||
skip_bits1(&h->gb); //repeat_first_field
|
||||
h->pic_qp_fixed =
|
||||
h->qp_fixed = get_bits1(&h->gb);
|
||||
h->qp = get_bits(&h->gb, 6);
|
||||
if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#ifndef AVCODEC_DIRAC_ARITH_H
|
||||
#define AVCODEC_DIRAC_ARITH_H
|
||||
|
||||
#include "libavutil/x86/asm.h"
|
||||
#include "bytestream.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
@@ -134,7 +135,7 @@ static inline int dirac_get_arith_bit(DiracArith *c, int ctx)
|
||||
|
||||
range_times_prob = (c->range * prob_zero) >> 16;
|
||||
|
||||
#if HAVE_FAST_CMOV && HAVE_INLINE_ASM
|
||||
#if HAVE_FAST_CMOV && HAVE_INLINE_ASM && HAVE_6REGS
|
||||
low -= range_times_prob << 16;
|
||||
range -= range_times_prob;
|
||||
bit = 0;
|
||||
|
||||
+39
-12
@@ -201,6 +201,7 @@ typedef struct DiracContext {
|
||||
|
||||
uint16_t *mctmp; /* buffer holding the MC data multipled by OBMC weights */
|
||||
uint8_t *mcscratch;
|
||||
int buffer_stride;
|
||||
|
||||
DECLARE_ALIGNED(16, uint8_t, obmc_weight)[3][MAX_BLOCKSIZE*MAX_BLOCKSIZE];
|
||||
|
||||
@@ -343,22 +344,44 @@ static int alloc_sequence_buffers(DiracContext *s)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
w = s->source.width;
|
||||
h = s->source.height;
|
||||
|
||||
/* fixme: allocate using real stride here */
|
||||
s->sbsplit = av_malloc(sbwidth * sbheight);
|
||||
s->blmotion = av_malloc(sbwidth * sbheight * 16 * sizeof(*s->blmotion));
|
||||
s->edge_emu_buffer_base = av_malloc((w+64)*MAX_BLOCKSIZE);
|
||||
s->sbsplit = av_malloc_array(sbwidth, sbheight);
|
||||
s->blmotion = av_malloc_array(sbwidth, sbheight * 16 * sizeof(*s->blmotion));
|
||||
|
||||
s->mctmp = av_malloc((w+64+MAX_BLOCKSIZE) * (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
|
||||
s->mcscratch = av_malloc((w+64)*MAX_BLOCKSIZE);
|
||||
|
||||
if (!s->sbsplit || !s->blmotion || !s->mctmp || !s->mcscratch)
|
||||
if (!s->sbsplit || !s->blmotion)
|
||||
return AVERROR(ENOMEM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int alloc_buffers(DiracContext *s, int stride)
|
||||
{
|
||||
int w = s->source.width;
|
||||
int h = s->source.height;
|
||||
|
||||
av_assert0(stride >= w);
|
||||
stride += 64;
|
||||
|
||||
if (s->buffer_stride >= stride)
|
||||
return 0;
|
||||
s->buffer_stride = 0;
|
||||
|
||||
av_freep(&s->edge_emu_buffer_base);
|
||||
memset(s->edge_emu_buffer, 0, sizeof(s->edge_emu_buffer));
|
||||
av_freep(&s->mctmp);
|
||||
av_freep(&s->mcscratch);
|
||||
|
||||
s->edge_emu_buffer_base = av_malloc_array(stride, MAX_BLOCKSIZE);
|
||||
|
||||
s->mctmp = av_malloc_array((stride+MAX_BLOCKSIZE), (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
|
||||
s->mcscratch = av_malloc_array(stride, MAX_BLOCKSIZE);
|
||||
|
||||
if (!s->edge_emu_buffer_base || !s->mctmp || !s->mcscratch)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
s->buffer_stride = stride;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void free_sequence_buffers(DiracContext *s)
|
||||
{
|
||||
int i, j, k;
|
||||
@@ -382,6 +405,7 @@ static void free_sequence_buffers(DiracContext *s)
|
||||
av_freep(&s->plane[i].idwt_tmp);
|
||||
}
|
||||
|
||||
s->buffer_stride = 0;
|
||||
av_freep(&s->sbsplit);
|
||||
av_freep(&s->blmotion);
|
||||
av_freep(&s->edge_emu_buffer_base);
|
||||
@@ -1360,8 +1384,8 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
|
||||
motion_y >>= s->chroma_y_shift;
|
||||
}
|
||||
|
||||
mx = motion_x & ~(-1 << s->mv_precision);
|
||||
my = motion_y & ~(-1 << s->mv_precision);
|
||||
mx = motion_x & ~(-1U << s->mv_precision);
|
||||
my = motion_y & ~(-1U << s->mv_precision);
|
||||
motion_x >>= s->mv_precision;
|
||||
motion_y >>= s->mv_precision;
|
||||
/* normalize subpel coordinates to epel */
|
||||
@@ -1836,6 +1860,9 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
|
||||
s->plane[1].stride = pic->avframe->linesize[1];
|
||||
s->plane[2].stride = pic->avframe->linesize[2];
|
||||
|
||||
if (alloc_buffers(s, FFMAX3(FFABS(s->plane[0].stride), FFABS(s->plane[1].stride), FFABS(s->plane[2].stride))) < 0)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
/* [DIRAC_STD] 11.1 Picture parse. picture_parse() */
|
||||
if (dirac_decode_picture_header(s))
|
||||
return -1;
|
||||
|
||||
@@ -235,7 +235,7 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)
|
||||
|
||||
static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx)
|
||||
{
|
||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail);
|
||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*(ctx->m.avctx->qmax + 1)*sizeof(RCEntry), fail);
|
||||
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
|
||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);
|
||||
|
||||
|
||||
+2
-1
@@ -709,7 +709,8 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Unknown compression method %d\n",
|
||||
c->compression);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
ret = AVERROR_PATCHWELCOME;
|
||||
goto header_fail;
|
||||
}
|
||||
c->tile_width = bytestream2_get_be32(&bc);
|
||||
c->tile_height = bytestream2_get_be32(&bc);
|
||||
|
||||
+2
-1
@@ -2285,7 +2285,8 @@ static int pack_bitstream(G723_1_Context *p, unsigned char *frame, int size)
|
||||
if (p->cur_rate == RATE_6300) {
|
||||
info_bits = 0;
|
||||
put_bits(&pb, 2, info_bits);
|
||||
}
|
||||
}else
|
||||
av_assert0(0);
|
||||
|
||||
put_bits(&pb, 8, p->lsp_index[2]);
|
||||
put_bits(&pb, 8, p->lsp_index[1]);
|
||||
|
||||
@@ -58,7 +58,7 @@ int main(void)
|
||||
}
|
||||
}
|
||||
|
||||
#define EXTEND(i) (i << 3 | i & 7)
|
||||
#define EXTEND(i) ((i) << 3 | (i) & 7)
|
||||
init_put_bits(&pb, temp, SIZE);
|
||||
for (i = 0; i < COUNT; i++)
|
||||
set_ue_golomb(&pb, EXTEND(i));
|
||||
|
||||
@@ -755,10 +755,9 @@ frame_end:
|
||||
}
|
||||
|
||||
if (startcode_found) {
|
||||
av_fast_malloc(&s->bitstream_buffer,
|
||||
av_fast_padded_mallocz(&s->bitstream_buffer,
|
||||
&s->allocated_bitstream_buffer_size,
|
||||
buf_size - current_pos +
|
||||
FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
buf_size - current_pos);
|
||||
if (!s->bitstream_buffer)
|
||||
return AVERROR(ENOMEM);
|
||||
memcpy(s->bitstream_buffer, buf + current_pos,
|
||||
|
||||
+47
-8
@@ -452,6 +452,18 @@ static int alloc_picture(H264Context *h, Picture *pic)
|
||||
pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
|
||||
}
|
||||
}
|
||||
if (!h->avctx->hwaccel && CONFIG_GRAY && h->flags & CODEC_FLAG_GRAY && pic->f.data[2]) {
|
||||
int h_chroma_shift, v_chroma_shift;
|
||||
av_pix_fmt_get_chroma_sub_sample(pic->f.format,
|
||||
&h_chroma_shift, &v_chroma_shift);
|
||||
|
||||
for(i=0; i<FF_CEIL_RSHIFT(h->avctx->height, v_chroma_shift); i++) {
|
||||
memset(pic->f.data[1] + pic->f.linesize[1]*i,
|
||||
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
|
||||
memset(pic->f.data[2] + pic->f.linesize[2]*i,
|
||||
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
|
||||
}
|
||||
}
|
||||
|
||||
if (!h->qscale_table_pool) {
|
||||
ret = init_table_pools(h);
|
||||
@@ -1787,6 +1799,7 @@ static int decode_update_thread_context(AVCodecContext *dst,
|
||||
memset(&h->mb, 0, sizeof(h->mb));
|
||||
memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
|
||||
memset(&h->mb_padding, 0, sizeof(h->mb_padding));
|
||||
memset(&h->cur_pic, 0, sizeof(h->cur_pic));
|
||||
|
||||
h->avctx = dst;
|
||||
h->DPB = NULL;
|
||||
@@ -3358,6 +3371,17 @@ int ff_set_ref_count(H264Context *h)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum AVPixelFormat non_j_pixfmt(enum AVPixelFormat a)
|
||||
{
|
||||
switch (a) {
|
||||
case AV_PIX_FMT_YUVJ420P: return AV_PIX_FMT_YUV420P;
|
||||
case AV_PIX_FMT_YUVJ422P: return AV_PIX_FMT_YUV422P;
|
||||
case AV_PIX_FMT_YUVJ444P: return AV_PIX_FMT_YUV444P;
|
||||
default:
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a slice header.
|
||||
* This will also call ff_MPV_common_init() and frame_start() as needed.
|
||||
@@ -3430,6 +3454,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
pps_id);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (h0->au_pps_id >= 0 && pps_id != h0->au_pps_id) {
|
||||
av_log(h->avctx, AV_LOG_ERROR,
|
||||
"PPS change from %d to %d forbidden\n",
|
||||
h0->au_pps_id, pps_id);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
h->pps = *h0->pps_buffers[pps_id];
|
||||
|
||||
if (!h0->sps_buffers[h->pps.sps_id]) {
|
||||
@@ -3441,9 +3471,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
|
||||
if (h->pps.sps_id != h->current_sps_id ||
|
||||
h0->sps_buffers[h->pps.sps_id]->new) {
|
||||
h0->sps_buffers[h->pps.sps_id]->new = 0;
|
||||
|
||||
h->current_sps_id = h->pps.sps_id;
|
||||
h->sps = *h0->sps_buffers[h->pps.sps_id];
|
||||
|
||||
if (h->mb_width != h->sps.mb_width ||
|
||||
@@ -3476,7 +3504,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
|| h->mb_width != h->sps.mb_width
|
||||
|| h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag)
|
||||
));
|
||||
if (h0->avctx->pix_fmt != get_pixel_format(h0, 0))
|
||||
if (non_j_pixfmt(h0->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h0, 0)))
|
||||
must_reinit = 1;
|
||||
|
||||
h->mb_width = h->sps.mb_width;
|
||||
@@ -3928,8 +3956,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
if (h->deblocking_filter) {
|
||||
h->slice_alpha_c0_offset += get_se_golomb(&h->gb) << 1;
|
||||
h->slice_beta_offset += get_se_golomb(&h->gb) << 1;
|
||||
if (h->slice_alpha_c0_offset > 104U ||
|
||||
h->slice_beta_offset > 104U) {
|
||||
if (h->slice_alpha_c0_offset < 52 - 12 || h->slice_alpha_c0_offset > 52 + 12 ||
|
||||
h->slice_beta_offset < 52 - 12 || h->slice_beta_offset > 52 + 12) {
|
||||
av_log(h->avctx, AV_LOG_ERROR,
|
||||
"deblocking filter parameters %d %d out of range\n",
|
||||
h->slice_alpha_c0_offset, h->slice_beta_offset);
|
||||
@@ -4022,6 +4050,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
if (h->ref_count[0]) h->er.last_pic = &h->ref_list[0][0];
|
||||
if (h->ref_count[1]) h->er.next_pic = &h->ref_list[1][0];
|
||||
h->er.ref_count = h->ref_count[0];
|
||||
h0->au_pps_id = pps_id;
|
||||
h->sps.new =
|
||||
h0->sps_buffers[h->pps.sps_id]->new = 0;
|
||||
h->current_sps_id = h->pps.sps_id;
|
||||
|
||||
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
|
||||
av_log(h->avctx, AV_LOG_DEBUG,
|
||||
@@ -4605,6 +4637,8 @@ static int execute_decode_slices(H264Context *h, int context_count)
|
||||
H264Context *hx;
|
||||
int i;
|
||||
|
||||
av_assert0(h->mb_y < h->mb_height);
|
||||
|
||||
if (h->avctx->hwaccel ||
|
||||
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
|
||||
return 0;
|
||||
@@ -4786,6 +4820,9 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
|
||||
continue;
|
||||
|
||||
again:
|
||||
if ( !(avctx->active_thread_type & FF_THREAD_FRAME)
|
||||
|| nals_needed >= nal_index)
|
||||
h->au_pps_id = -1;
|
||||
/* Ignore per frame NAL unit type during extradata
|
||||
* parsing. Decoding slices is not possible in codec init
|
||||
* with frame-mt */
|
||||
@@ -4818,6 +4855,7 @@ again:
|
||||
if(!idr_cleared)
|
||||
idr(h); // FIXME ensure we don't lose some frames if there is reordering
|
||||
idr_cleared = 1;
|
||||
h->has_recovery_point = 1;
|
||||
case NAL_SLICE:
|
||||
init_get_bits(&hx->gb, ptr, bit_length);
|
||||
hx->intra_gb_ptr =
|
||||
@@ -5008,6 +5046,7 @@ static int get_consumed_bytes(int pos, int buf_size)
|
||||
static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
|
||||
{
|
||||
AVFrame *src = &srcp->f;
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(src->format);
|
||||
int i;
|
||||
int ret = av_frame_ref(dst, src);
|
||||
if (ret < 0)
|
||||
@@ -5018,9 +5057,9 @@ static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
|
||||
if (!srcp->crop)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
int hshift = (i > 0) ? h->chroma_x_shift : 0;
|
||||
int vshift = (i > 0) ? h->chroma_y_shift : 0;
|
||||
for (i = 0; i < desc->nb_components; i++) {
|
||||
int hshift = (i > 0) ? desc->log2_chroma_w : 0;
|
||||
int vshift = (i > 0) ? desc->log2_chroma_h : 0;
|
||||
int off = ((srcp->crop_left >> hshift) << h->pixel_shift) +
|
||||
(srcp->crop_top >> vshift) * dst->linesize[i];
|
||||
dst->data[i] += off;
|
||||
|
||||
+12
-8
@@ -61,10 +61,10 @@
|
||||
#define MAX_SLICES 16
|
||||
|
||||
#ifdef ALLOW_INTERLACE
|
||||
#define MB_MBAFF(h) h->mb_mbaff
|
||||
#define MB_FIELD(h) h->mb_field_decoding_flag
|
||||
#define FRAME_MBAFF(h) h->mb_aff_frame
|
||||
#define FIELD_PICTURE(h) (h->picture_structure != PICT_FRAME)
|
||||
#define MB_MBAFF(h) (h)->mb_mbaff
|
||||
#define MB_FIELD(h) (h)->mb_field_decoding_flag
|
||||
#define FRAME_MBAFF(h) (h)->mb_aff_frame
|
||||
#define FIELD_PICTURE(h) ((h)->picture_structure != PICT_FRAME)
|
||||
#define LEFT_MBS 2
|
||||
#define LTOP 0
|
||||
#define LBOT 1
|
||||
@@ -84,12 +84,12 @@
|
||||
#define FIELD_OR_MBAFF_PICTURE(h) (FRAME_MBAFF(h) || FIELD_PICTURE(h))
|
||||
|
||||
#ifndef CABAC
|
||||
#define CABAC(h) h->pps.cabac
|
||||
#define CABAC(h) (h)->pps.cabac
|
||||
#endif
|
||||
|
||||
#define CHROMA(h) (h->sps.chroma_format_idc)
|
||||
#define CHROMA422(h) (h->sps.chroma_format_idc == 2)
|
||||
#define CHROMA444(h) (h->sps.chroma_format_idc == 3)
|
||||
#define CHROMA(h) ((h)->sps.chroma_format_idc)
|
||||
#define CHROMA422(h) ((h)->sps.chroma_format_idc == 2)
|
||||
#define CHROMA444(h) ((h)->sps.chroma_format_idc == 3)
|
||||
|
||||
#define EXTENDED_SAR 255
|
||||
|
||||
@@ -390,6 +390,8 @@ typedef struct H264Context {
|
||||
*/
|
||||
PPS pps; // FIXME move to Picture perhaps? (->no) do we need that?
|
||||
|
||||
int au_pps_id; ///< pps_id of current access unit
|
||||
|
||||
uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16]; // FIXME should these be moved down?
|
||||
uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
|
||||
uint32_t(*dequant4_coeff[6])[16];
|
||||
@@ -656,6 +658,8 @@ typedef struct H264Context {
|
||||
|
||||
FPA sei_fpa;
|
||||
|
||||
int has_recovery_point;
|
||||
|
||||
int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
|
||||
int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
|
||||
goto fail;
|
||||
|
||||
/* prepend only to the first type 5 NAL unit of an IDR picture */
|
||||
if (ctx->first_idr && unit_type == 5) {
|
||||
if (ctx->first_idr && (unit_type == 5 || unit_type == 7 || unit_type == 8)) {
|
||||
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
|
||||
avctx->extradata, avctx->extradata_size,
|
||||
buf, nal_size)) < 0)
|
||||
|
||||
@@ -740,7 +740,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
|
||||
if ( err >= 0
|
||||
&& h->long_ref_count==0
|
||||
&& (h->short_ref_count<=2 || h->pps.ref_count[0] <= 1 && h->pps.ref_count[1] <= 1 && pps_count == 1)
|
||||
&& h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME)
|
||||
&& h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) + (2*!h->has_recovery_point)
|
||||
&& h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
|
||||
h->cur_pic_ptr->sync |= 1;
|
||||
if(!h->avctx->has_b_frames)
|
||||
|
||||
@@ -184,6 +184,8 @@ static int decode_recovery_point(H264Context *h)
|
||||
if (h->avctx->debug & FF_DEBUG_PICT_INFO)
|
||||
av_log(h->avctx, AV_LOG_DEBUG, "sei_recovery_frame_cnt: %d\n", h->sei_recovery_frame_cnt);
|
||||
|
||||
h->has_recovery_point = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+96
-30
@@ -743,11 +743,10 @@ static void hls_sao_param(HEVCContext *s, int rx, int ry)
|
||||
#undef SET_SAO
|
||||
#undef CTB
|
||||
|
||||
|
||||
static void hls_transform_unit(HEVCContext *s, int x0, int y0,
|
||||
int xBase, int yBase, int cb_xBase, int cb_yBase,
|
||||
int log2_cb_size, int log2_trafo_size,
|
||||
int trafo_depth, int blk_idx)
|
||||
static int hls_transform_unit(HEVCContext *s, int x0, int y0,
|
||||
int xBase, int yBase, int cb_xBase, int cb_yBase,
|
||||
int log2_cb_size, int log2_trafo_size,
|
||||
int trafo_depth, int blk_idx)
|
||||
{
|
||||
HEVCLocalContext *lc = s->HEVClc;
|
||||
|
||||
@@ -781,6 +780,18 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0,
|
||||
if (ff_hevc_cu_qp_delta_sign_flag(s) == 1)
|
||||
lc->tu.cu_qp_delta = -lc->tu.cu_qp_delta;
|
||||
lc->tu.is_cu_qp_delta_coded = 1;
|
||||
|
||||
if (lc->tu.cu_qp_delta < -(26 + s->sps->qp_bd_offset / 2) ||
|
||||
lc->tu.cu_qp_delta > (25 + s->sps->qp_bd_offset / 2)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"The cu_qp_delta %d is outside the valid range "
|
||||
"[%d, %d].\n",
|
||||
lc->tu.cu_qp_delta,
|
||||
-(26 + s->sps->qp_bd_offset / 2),
|
||||
(25 + s->sps->qp_bd_offset / 2));
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
ff_hevc_set_qPy(s, x0, y0, cb_xBase, cb_yBase, log2_cb_size);
|
||||
}
|
||||
|
||||
@@ -816,6 +827,7 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0,
|
||||
ff_hevc_hls_residual_coding(s, xBase, yBase, log2_trafo_size, scan_idx_c, 2);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||
@@ -833,13 +845,14 @@ static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_si
|
||||
s->is_pcm[i + j * min_pu_width] = 2;
|
||||
}
|
||||
|
||||
static void hls_transform_tree(HEVCContext *s, int x0, int y0,
|
||||
int xBase, int yBase, int cb_xBase, int cb_yBase,
|
||||
int log2_cb_size, int log2_trafo_size,
|
||||
int trafo_depth, int blk_idx)
|
||||
static int hls_transform_tree(HEVCContext *s, int x0, int y0,
|
||||
int xBase, int yBase, int cb_xBase, int cb_yBase,
|
||||
int log2_cb_size, int log2_trafo_size,
|
||||
int trafo_depth, int blk_idx)
|
||||
{
|
||||
HEVCLocalContext *lc = s->HEVClc;
|
||||
uint8_t split_transform_flag;
|
||||
int ret;
|
||||
|
||||
if (trafo_depth > 0 && log2_trafo_size == 2) {
|
||||
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) =
|
||||
@@ -892,14 +905,26 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
|
||||
int x1 = x0 + ((1 << log2_trafo_size) >> 1);
|
||||
int y1 = y0 + ((1 << log2_trafo_size) >> 1);
|
||||
|
||||
hls_transform_tree(s, x0, y0, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
|
||||
log2_trafo_size - 1, trafo_depth + 1, 0);
|
||||
hls_transform_tree(s, x1, y0, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
|
||||
log2_trafo_size - 1, trafo_depth + 1, 1);
|
||||
hls_transform_tree(s, x0, y1, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
|
||||
log2_trafo_size - 1, trafo_depth + 1, 2);
|
||||
hls_transform_tree(s, x1, y1, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
|
||||
log2_trafo_size - 1, trafo_depth + 1, 3);
|
||||
ret = hls_transform_tree(s, x0, y0, x0, y0, cb_xBase, cb_yBase,
|
||||
log2_cb_size, log2_trafo_size - 1,
|
||||
trafo_depth + 1, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = hls_transform_tree(s, x1, y0, x0, y0, cb_xBase, cb_yBase,
|
||||
log2_cb_size, log2_trafo_size - 1,
|
||||
trafo_depth + 1, 1);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = hls_transform_tree(s, x0, y1, x0, y0, cb_xBase, cb_yBase,
|
||||
log2_cb_size, log2_trafo_size - 1,
|
||||
trafo_depth + 1, 2);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = hls_transform_tree(s, x1, y1, x0, y0, cb_xBase, cb_yBase,
|
||||
log2_cb_size, log2_trafo_size - 1,
|
||||
trafo_depth + 1, 3);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else {
|
||||
int min_tu_size = 1 << s->sps->log2_min_tb_size;
|
||||
int log2_min_tu_size = s->sps->log2_min_tb_size;
|
||||
@@ -911,9 +936,11 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
|
||||
lc->tt.cbf_luma = ff_hevc_cbf_luma_decode(s, trafo_depth);
|
||||
}
|
||||
|
||||
hls_transform_unit(s, x0, y0, xBase, yBase, cb_xBase, cb_yBase,
|
||||
log2_cb_size, log2_trafo_size, trafo_depth, blk_idx);
|
||||
|
||||
ret = hls_transform_unit(s, x0, y0, xBase, yBase, cb_xBase, cb_yBase,
|
||||
log2_cb_size, log2_trafo_size, trafo_depth,
|
||||
blk_idx);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
// TODO: store cbf_luma somewhere else
|
||||
if (lc->tt.cbf_luma) {
|
||||
int i, j;
|
||||
@@ -932,6 +959,7 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
|
||||
set_deblocking_bypass(s, x0, y0, log2_trafo_size);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||
@@ -1520,7 +1548,8 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||
int min_cb_width = s->sps->min_cb_width;
|
||||
int x_cb = x0 >> log2_min_cb_size;
|
||||
int y_cb = y0 >> log2_min_cb_size;
|
||||
int x, y;
|
||||
int x, y, ret;
|
||||
int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1;
|
||||
|
||||
lc->cu.x = x0;
|
||||
lc->cu.y = y0;
|
||||
@@ -1577,7 +1606,6 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||
lc->cu.pcm_flag = ff_hevc_pcm_flag_decode(s);
|
||||
}
|
||||
if (lc->cu.pcm_flag) {
|
||||
int ret;
|
||||
intra_prediction_unit_default_value(s, x0, y0, log2_cb_size);
|
||||
ret = hls_pcm_sample(s, x0, y0, log2_cb_size);
|
||||
if (s->sps->pcm.loop_filter_disable_flag)
|
||||
@@ -1636,8 +1664,11 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||
lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ?
|
||||
s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag :
|
||||
s->sps->max_transform_hierarchy_depth_inter;
|
||||
hls_transform_tree(s, x0, y0, x0, y0, x0, y0, log2_cb_size,
|
||||
log2_cb_size, 0, 0);
|
||||
ret = hls_transform_tree(s, x0, y0, x0, y0, x0, y0,
|
||||
log2_cb_size,
|
||||
log2_cb_size, 0, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else {
|
||||
if (!s->sh.disable_deblocking_filter_flag)
|
||||
ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size,
|
||||
@@ -1656,6 +1687,11 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||
x += min_cb_width;
|
||||
}
|
||||
|
||||
if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
|
||||
((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
|
||||
lc->qPy_pred = lc->qp_y;
|
||||
}
|
||||
|
||||
set_ct_depth(s, x0, y0, log2_cb_size, lc->ct.depth);
|
||||
|
||||
return 0;
|
||||
@@ -1667,6 +1703,7 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0,
|
||||
HEVCLocalContext *lc = s->HEVClc;
|
||||
const int cb_size = 1 << log2_cb_size;
|
||||
int ret;
|
||||
int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1;
|
||||
|
||||
lc->ct.depth = cb_depth;
|
||||
if ((x0 + cb_size <= s->sps->width) &&
|
||||
@@ -1694,14 +1731,27 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0,
|
||||
if (more_data < 0)
|
||||
return more_data;
|
||||
|
||||
if (more_data && x1 < s->sps->width)
|
||||
if (more_data && x1 < s->sps->width) {
|
||||
more_data = hls_coding_quadtree(s, x1, y0, log2_cb_size - 1, cb_depth + 1);
|
||||
if (more_data && y1 < s->sps->height)
|
||||
if (more_data < 0)
|
||||
return more_data;
|
||||
}
|
||||
if (more_data && y1 < s->sps->height) {
|
||||
more_data = hls_coding_quadtree(s, x0, y1, log2_cb_size - 1, cb_depth + 1);
|
||||
if (more_data < 0)
|
||||
return more_data;
|
||||
}
|
||||
if (more_data && x1 < s->sps->width &&
|
||||
y1 < s->sps->height) {
|
||||
return hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1);
|
||||
more_data = hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1);
|
||||
if (more_data < 0)
|
||||
return more_data;
|
||||
}
|
||||
|
||||
if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
|
||||
((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
|
||||
lc->qPy_pred = lc->qp_y;
|
||||
|
||||
if (more_data)
|
||||
return ((x1 + cb_size_split) < s->sps->width ||
|
||||
(y1 + cb_size_split) < s->sps->height);
|
||||
@@ -1795,6 +1845,14 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (s->sh.dependent_slice_segment_flag) {
|
||||
int prev_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
|
||||
if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
while (more_data && ctb_addr_ts < s->sps->ctb_size) {
|
||||
int ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts];
|
||||
|
||||
@@ -1811,8 +1869,11 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
|
||||
s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag;
|
||||
|
||||
more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0);
|
||||
if (more_data < 0)
|
||||
if (more_data < 0) {
|
||||
s->tab_slice_address[ctb_addr_rs] = -1;
|
||||
return more_data;
|
||||
}
|
||||
|
||||
|
||||
ctb_addr_ts++;
|
||||
ff_hevc_save_states(s, ctb_addr_ts);
|
||||
@@ -1878,8 +1939,10 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int
|
||||
hls_sao_param(s, x_ctb >> s->sps->log2_ctb_size, y_ctb >> s->sps->log2_ctb_size);
|
||||
more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0);
|
||||
|
||||
if (more_data < 0)
|
||||
if (more_data < 0) {
|
||||
s->tab_slice_address[ctb_addr_rs] = -1;
|
||||
return more_data;
|
||||
}
|
||||
|
||||
ctb_addr_ts++;
|
||||
|
||||
@@ -2043,13 +2106,16 @@ static void restore_tqb_pixels(HEVCContext *s)
|
||||
|
||||
static int hevc_frame_start(HEVCContext *s)
|
||||
{
|
||||
HEVCLocalContext *lc = s->HEVClc;
|
||||
HEVCLocalContext *lc = s->HEVClc;
|
||||
int pic_size_in_ctb = ((s->sps->width >> s->sps->log2_min_cb_size) + 1) *
|
||||
((s->sps->height >> s->sps->log2_min_cb_size) + 1);
|
||||
int ret;
|
||||
|
||||
memset(s->horizontal_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
||||
memset(s->vertical_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
||||
memset(s->cbf_luma, 0, s->sps->min_tb_width * s->sps->min_tb_height);
|
||||
memset(s->is_pcm, 0, s->sps->min_pu_width * s->sps->min_pu_height);
|
||||
memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address));
|
||||
|
||||
lc->start_of_tiles_x = 0;
|
||||
s->is_decoded = 0;
|
||||
|
||||
+4
-2
@@ -373,7 +373,7 @@ typedef struct ScalingList {
|
||||
} ScalingList;
|
||||
|
||||
typedef struct HEVCSPS {
|
||||
int vps_id;
|
||||
unsigned vps_id;
|
||||
int chroma_format_idc;
|
||||
uint8_t separate_colour_plane_flag;
|
||||
|
||||
@@ -454,7 +454,7 @@ typedef struct HEVCSPS {
|
||||
} HEVCSPS;
|
||||
|
||||
typedef struct HEVCPPS {
|
||||
int sps_id; ///< seq_parameter_set_id
|
||||
unsigned sps_id; ///< seq_parameter_set_id
|
||||
|
||||
uint8_t sign_data_hiding_flag;
|
||||
|
||||
@@ -733,6 +733,8 @@ typedef struct HEVCLocalContext {
|
||||
int8_t qp_y;
|
||||
int8_t curr_qp_y;
|
||||
|
||||
int qPy_pred;
|
||||
|
||||
TransformUnit tu;
|
||||
|
||||
uint8_t ctb_left_flag;
|
||||
|
||||
@@ -93,45 +93,7 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, in
|
||||
lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded;
|
||||
qPy_pred = s->sh.slice_qp;
|
||||
} else {
|
||||
qPy_pred = lc->qp_y;
|
||||
if (log2_cb_size < s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth) {
|
||||
static const int offsetX[8][8] = {
|
||||
{-1, 1, 3, 1, 7, 1, 3, 1},
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 1, 3, 1, 3, 1, 3, 1, 3},
|
||||
{ 2, 2, 2, 2, 2, 2, 2, 2},
|
||||
{ 3, 5, 7, 5, 3, 5, 7, 5},
|
||||
{ 4, 4, 4, 4, 4, 4, 4, 4},
|
||||
{ 5, 7, 5, 7, 5, 7, 5, 7},
|
||||
{ 6, 6, 6, 6, 6, 6, 6, 6}
|
||||
};
|
||||
static const int offsetY[8][8] = {
|
||||
{ 7, 0, 1, 2, 3, 4, 5, 6},
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7},
|
||||
{ 1, 0, 3, 2, 5, 4, 7, 6},
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7},
|
||||
{ 3, 0, 1, 2, 7, 4, 5, 6},
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7},
|
||||
{ 1, 0, 3, 2, 5, 4, 7, 6},
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7}
|
||||
};
|
||||
int xC0b = (xC - (xC & ctb_size_mask)) >> s->sps->log2_min_cb_size;
|
||||
int yC0b = (yC - (yC & ctb_size_mask)) >> s->sps->log2_min_cb_size;
|
||||
int idxX = (xQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size;
|
||||
int idxY = (yQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size;
|
||||
int idx_mask = ctb_size_mask >> s->sps->log2_min_cb_size;
|
||||
int x, y;
|
||||
|
||||
x = FFMIN(xC0b + offsetX[idxX][idxY], min_cb_width - 1);
|
||||
y = FFMIN(yC0b + (offsetY[idxX][idxY] & idx_mask), min_cb_height - 1);
|
||||
|
||||
if (xC0b == (lc->start_of_tiles_x >> s->sps->log2_min_cb_size) &&
|
||||
offsetX[idxX][idxY] == -1) {
|
||||
x = (lc->end_of_tiles_x >> s->sps->log2_min_cb_size) - 1;
|
||||
y = yC0b - 1;
|
||||
}
|
||||
qPy_pred = s->qp_y_tab[y * min_cb_width + x];
|
||||
}
|
||||
qPy_pred = lc->qPy_pred;
|
||||
}
|
||||
|
||||
// qPy_a
|
||||
|
||||
@@ -489,8 +489,8 @@ static void decode_vui(HEVCContext *s, HEVCSPS *sps)
|
||||
|
||||
vui->vui_timing_info_present_flag = get_bits1(gb);
|
||||
if (vui->vui_timing_info_present_flag) {
|
||||
vui->vui_num_units_in_tick = get_bits(gb, 32);
|
||||
vui->vui_time_scale = get_bits(gb, 32);
|
||||
vui->vui_num_units_in_tick = get_bits_long(gb, 32);
|
||||
vui->vui_time_scale = get_bits_long(gb, 32);
|
||||
vui->vui_poc_proportional_to_timing_flag = get_bits1(gb);
|
||||
if (vui->vui_poc_proportional_to_timing_flag)
|
||||
vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb);
|
||||
|
||||
+19
-19
@@ -235,15 +235,15 @@ void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8_t *dst,
|
||||
|
||||
/** butterfly operation for the inverse Haar transform */
|
||||
#define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \
|
||||
t = (s1 - s2) >> 1;\
|
||||
o1 = (s1 + s2) >> 1;\
|
||||
o2 = t;\
|
||||
t = ((s1) - (s2)) >> 1;\
|
||||
o1 = ((s1) + (s2)) >> 1;\
|
||||
o2 = (t);\
|
||||
|
||||
/** inverse 8-point Haar transform */
|
||||
#define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\
|
||||
d1, d2, d3, d4, d5, d6, d7, d8,\
|
||||
t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
|
||||
t1 = s1 << 1; t5 = s5 << 1;\
|
||||
t1 = (s1) << 1; t5 = (s5) << 1;\
|
||||
IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\
|
||||
IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\
|
||||
IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\
|
||||
@@ -485,21 +485,21 @@ void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch,
|
||||
|
||||
/** butterfly operation for the inverse slant transform */
|
||||
#define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \
|
||||
t = s1 - s2;\
|
||||
o1 = s1 + s2;\
|
||||
o2 = t;\
|
||||
t = (s1) - (s2);\
|
||||
o1 = (s1) + (s2);\
|
||||
o2 = (t);\
|
||||
|
||||
/** This is a reflection a,b = 1/2, 5/4 for the inverse slant transform */
|
||||
#define IVI_IREFLECT(s1, s2, o1, o2, t) \
|
||||
t = ((s1 + s2*2 + 2) >> 2) + s1;\
|
||||
o2 = ((s1*2 - s2 + 2) >> 2) - s2;\
|
||||
o1 = t;\
|
||||
t = (((s1) + (s2)*2 + 2) >> 2) + (s1);\
|
||||
o2 = (((s1)*2 - (s2) + 2) >> 2) - (s2);\
|
||||
o1 = (t);\
|
||||
|
||||
/** This is a reflection a,b = 1/2, 7/8 for the inverse slant transform */
|
||||
#define IVI_SLANT_PART4(s1, s2, o1, o2, t) \
|
||||
t = s2 + ((s1*4 - s2 + 4) >> 3);\
|
||||
o2 = s1 + ((-s1 - s2*4 + 4) >> 3);\
|
||||
o1 = t;\
|
||||
t = (s2) + (((s1)*4 - (s2) + 4) >> 3);\
|
||||
o2 = (s1) + ((-(s1) - (s2)*4 + 4) >> 3);\
|
||||
o1 = (t);\
|
||||
|
||||
/** inverse slant8 transform */
|
||||
#define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7,\
|
||||
@@ -557,7 +557,7 @@ void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch, c
|
||||
}
|
||||
#undef COMPENSATE
|
||||
|
||||
#define COMPENSATE(x) ((x + 1)>>1)
|
||||
#define COMPENSATE(x) (((x) + 1)>>1)
|
||||
src = tmp;
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) {
|
||||
@@ -597,7 +597,7 @@ void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch, c
|
||||
}
|
||||
#undef COMPENSATE
|
||||
|
||||
#define COMPENSATE(x) ((x + 1)>>1)
|
||||
#define COMPENSATE(x) (((x) + 1)>>1)
|
||||
src = tmp;
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (!src[0] && !src[1] && !src[2] && !src[3]) {
|
||||
@@ -631,7 +631,7 @@ void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const ui
|
||||
int i;
|
||||
int t0, t1, t2, t3, t4, t5, t6, t7, t8;
|
||||
|
||||
#define COMPENSATE(x) ((x + 1)>>1)
|
||||
#define COMPENSATE(x) (((x) + 1)>>1)
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) {
|
||||
memset(out, 0, 8*sizeof(out[0]));
|
||||
@@ -673,7 +673,7 @@ void ff_ivi_col_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const ui
|
||||
row4 = pitch << 2;
|
||||
row8 = pitch << 3;
|
||||
|
||||
#define COMPENSATE(x) ((x + 1)>>1)
|
||||
#define COMPENSATE(x) (((x) + 1)>>1)
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (flags[i]) {
|
||||
IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56],
|
||||
@@ -710,7 +710,7 @@ void ff_ivi_row_slant4(const int32_t *in, int16_t *out, uint32_t pitch, const ui
|
||||
int i;
|
||||
int t0, t1, t2, t3, t4;
|
||||
|
||||
#define COMPENSATE(x) ((x + 1)>>1)
|
||||
#define COMPENSATE(x) (((x) + 1)>>1)
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (!in[0] && !in[1] && !in[2] && !in[3]) {
|
||||
memset(out, 0, 4*sizeof(out[0]));
|
||||
@@ -732,7 +732,7 @@ void ff_ivi_col_slant4(const int32_t *in, int16_t *out, uint32_t pitch, const ui
|
||||
|
||||
row2 = pitch << 1;
|
||||
|
||||
#define COMPENSATE(x) ((x + 1)>>1)
|
||||
#define COMPENSATE(x) (((x) + 1)>>1)
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (flags[i]) {
|
||||
IVI_INV_SLANT4(in[0], in[4], in[8], in[12],
|
||||
|
||||
@@ -344,7 +344,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) {
|
||||
if (i == possible_fmts_nb) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Unknown pix_fmt, profile: %d, colour_space: %d, "
|
||||
"components: %d, precision: %d, "
|
||||
@@ -354,6 +354,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
|
||||
ncomponents > 2 ? s->cdy[1] : 0,
|
||||
ncomponents > 2 ? s->cdx[2] : 0,
|
||||
ncomponents > 2 ? s->cdy[2] : 0);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
s->avctx->bits_per_raw_sample = s->precision;
|
||||
return 0;
|
||||
|
||||
@@ -350,7 +350,8 @@ static int oggvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
avctx->delay = duration;
|
||||
av_assert0(!s->afq.remaining_delay);
|
||||
s->afq.frames->duration += duration;
|
||||
s->afq.frames->pts -= duration;
|
||||
if (s->afq.frames->pts != AV_NOPTS_VALUE)
|
||||
s->afq.frames->pts -= duration;
|
||||
s->afq.remaining_samples += duration;
|
||||
}
|
||||
ff_af_queue_remove(&s->afq, duration, &avpkt->pts, &avpkt->duration);
|
||||
|
||||
+13
-13
@@ -355,19 +355,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
||||
|
||||
OPT_STR("level", x4->level);
|
||||
|
||||
if(x4->x264opts){
|
||||
const char *p= x4->x264opts;
|
||||
while(p){
|
||||
char param[256]={0}, val[256]={0};
|
||||
if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){
|
||||
OPT_STR(param, "1");
|
||||
}else
|
||||
OPT_STR(param, val);
|
||||
p= strchr(p, ':');
|
||||
p+=!!p;
|
||||
}
|
||||
}
|
||||
|
||||
if (avctx->i_quant_factor > 0)
|
||||
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
|
||||
|
||||
@@ -543,6 +530,19 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
||||
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
|
||||
x4->params.b_repeat_headers = 0;
|
||||
|
||||
if(x4->x264opts){
|
||||
const char *p= x4->x264opts;
|
||||
while(p){
|
||||
char param[256]={0}, val[256]={0};
|
||||
if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){
|
||||
OPT_STR(param, "1");
|
||||
}else
|
||||
OPT_STR(param, val);
|
||||
p= strchr(p, ':');
|
||||
p+=!!p;
|
||||
}
|
||||
}
|
||||
|
||||
if (x4->x264_params) {
|
||||
AVDictionary *dict = NULL;
|
||||
AVDictionaryEntry *en = NULL;
|
||||
|
||||
@@ -110,10 +110,10 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int XAVS_frame(AVCodecContext *ctx, AVPacket *pkt,
|
||||
static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
const AVFrame *frame, int *got_packet)
|
||||
{
|
||||
XavsContext *x4 = ctx->priv_data;
|
||||
XavsContext *x4 = avctx->priv_data;
|
||||
xavs_nal_t *nal;
|
||||
int nnal, i, ret;
|
||||
xavs_picture_t pic_out;
|
||||
@@ -129,29 +129,29 @@ static int XAVS_frame(AVCodecContext *ctx, AVPacket *pkt,
|
||||
|
||||
x4->pic.i_pts = frame->pts;
|
||||
x4->pic.i_type = XAVS_TYPE_AUTO;
|
||||
x4->pts_buffer[ctx->frame_number % (ctx->max_b_frames+1)] = frame->pts;
|
||||
x4->pts_buffer[avctx->frame_number % (avctx->max_b_frames+1)] = frame->pts;
|
||||
}
|
||||
|
||||
if (xavs_encoder_encode(x4->enc, &nal, &nnal,
|
||||
frame? &x4->pic: NULL, &pic_out) < 0)
|
||||
return -1;
|
||||
|
||||
ret = encode_nals(ctx, pkt, nal, nnal);
|
||||
ret = encode_nals(avctx, pkt, nal, nnal);
|
||||
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
if (!ret) {
|
||||
if (!frame && !(x4->end_of_stream)) {
|
||||
if ((ret = ff_alloc_packet2(ctx, pkt, 4)) < 0)
|
||||
if ((ret = ff_alloc_packet2(avctx, pkt, 4)) < 0)
|
||||
return ret;
|
||||
|
||||
pkt->data[0] = 0x0;
|
||||
pkt->data[1] = 0x0;
|
||||
pkt->data[2] = 0x01;
|
||||
pkt->data[3] = 0xb1;
|
||||
pkt->dts = 2*x4->pts_buffer[(x4->out_frame_count-1)%(ctx->max_b_frames+1)] -
|
||||
x4->pts_buffer[(x4->out_frame_count-2)%(ctx->max_b_frames+1)];
|
||||
pkt->dts = 2*x4->pts_buffer[(x4->out_frame_count-1)%(avctx->max_b_frames+1)] -
|
||||
x4->pts_buffer[(x4->out_frame_count-2)%(avctx->max_b_frames+1)];
|
||||
x4->end_of_stream = END_OF_STREAM;
|
||||
*got_packet = 1;
|
||||
}
|
||||
@@ -160,11 +160,11 @@ static int XAVS_frame(AVCodecContext *ctx, AVPacket *pkt,
|
||||
|
||||
avctx->coded_frame->pts = pic_out.i_pts;
|
||||
pkt->pts = pic_out.i_pts;
|
||||
if (ctx->has_b_frames) {
|
||||
if (avctx->has_b_frames) {
|
||||
if (!x4->out_frame_count)
|
||||
pkt->dts = pkt->pts - (x4->pts_buffer[1] - x4->pts_buffer[0]);
|
||||
else
|
||||
pkt->dts = x4->pts_buffer[(x4->out_frame_count-1)%(ctx->max_b_frames+1)];
|
||||
pkt->dts = x4->pts_buffer[(x4->out_frame_count-1)%(avctx->max_b_frames+1)];
|
||||
} else
|
||||
pkt->dts = pkt->pts;
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
* This stores all the private context for the codec.
|
||||
*/
|
||||
struct xvid_context {
|
||||
AVClass *class;
|
||||
void *encoder_handle; /**< Handle for Xvid encoder */
|
||||
int xsize; /**< Frame x size */
|
||||
int ysize; /**< Frame y size */
|
||||
|
||||
@@ -119,7 +119,7 @@ read_header:
|
||||
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
|
||||
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
|
||||
s->start_code = SOS;
|
||||
if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 &&
|
||||
if (ff_mjpeg_decode_sos(s, NULL, 0, NULL) < 0 &&
|
||||
(avctx->err_recognition & AV_EF_EXPLODE))
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
+16
-11
@@ -334,7 +334,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
||||
s->first_picture = 0;
|
||||
}
|
||||
|
||||
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
|
||||
if (s->got_picture && s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
|
||||
if (s->progressive) {
|
||||
avpriv_request_sample(s->avctx, "progressively coded interlaced picture");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -1092,6 +1092,7 @@ static void shift_output(MJpegDecodeContext *s, uint8_t *ptr, int linesize)
|
||||
|
||||
static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
|
||||
int Al, const uint8_t *mb_bitmask,
|
||||
int mb_bitmask_size,
|
||||
const AVFrame *reference)
|
||||
{
|
||||
int i, mb_x, mb_y;
|
||||
@@ -1101,8 +1102,13 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
|
||||
GetBitContext mb_bitmask_gb;
|
||||
int bytes_per_pixel = 1 + (s->bits > 8);
|
||||
|
||||
if (mb_bitmask)
|
||||
if (mb_bitmask) {
|
||||
if (mb_bitmask_size != (s->mb_width * s->mb_height + 7)>>3) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "mb_bitmask_size mismatches\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width * s->mb_height);
|
||||
}
|
||||
|
||||
if (s->flipped && s->avctx->lowres) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Can not flip image with lowres\n");
|
||||
@@ -1223,7 +1229,7 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
|
||||
}
|
||||
|
||||
if (!Al) {
|
||||
s->coefs_finished[c] |= (1LL << (se + 1)) - (1LL << ss);
|
||||
s->coefs_finished[c] |= (2LL << se) - (1LL << ss);
|
||||
last_scan = !~s->coefs_finished[c];
|
||||
}
|
||||
|
||||
@@ -1268,7 +1274,7 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
|
||||
}
|
||||
|
||||
int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
|
||||
const AVFrame *reference)
|
||||
int mb_bitmask_size, const AVFrame *reference)
|
||||
{
|
||||
int len, nb_components, i, h, v, predictor, point_transform;
|
||||
int index, id, ret;
|
||||
@@ -1400,7 +1406,7 @@ next_field:
|
||||
} else {
|
||||
if ((ret = mjpeg_decode_scan(s, nb_components,
|
||||
prev_shift, point_transform,
|
||||
mb_bitmask, reference)) < 0)
|
||||
mb_bitmask, mb_bitmask_size, reference)) < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -1650,7 +1656,7 @@ static int mjpeg_decode_com(MJpegDecodeContext *s)
|
||||
s->interlace_polarity = 1;
|
||||
} else if (!strcmp(cbuf, "CS=ITU601"))
|
||||
s->cs_itu601 = 1;
|
||||
else if ((!strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32)) ||
|
||||
else if ((!strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32) && s->avctx->codec_tag) ||
|
||||
(!strncmp(cbuf, "Metasoft MJPEG Codec", 20)))
|
||||
s->flipped = 1;
|
||||
|
||||
@@ -1735,8 +1741,6 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
|
||||
int t = 0, b = 0;
|
||||
PutBitContext pb;
|
||||
|
||||
s->cur_scan++;
|
||||
|
||||
/* find marker */
|
||||
while (src + t < buf_end) {
|
||||
uint8_t x = src[t++];
|
||||
@@ -1801,7 +1805,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
&unescaped_buf_size);
|
||||
/* EOF */
|
||||
if (start_code < 0) {
|
||||
goto the_end;
|
||||
break;
|
||||
} else if (unescaped_buf_size > INT_MAX / 8) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"MJPEG packet 0x%x too big (%d/%d), corrupt data?\n",
|
||||
@@ -1926,7 +1930,8 @@ eoi_parser:
|
||||
|
||||
goto the_end;
|
||||
case SOS:
|
||||
if ((ret = ff_mjpeg_decode_sos(s, NULL, NULL)) < 0 &&
|
||||
s->cur_scan++;
|
||||
if ((ret = ff_mjpeg_decode_sos(s, NULL, 0, NULL)) < 0 &&
|
||||
(avctx->err_recognition & AV_EF_EXPLODE))
|
||||
goto fail;
|
||||
break;
|
||||
@@ -1954,7 +1959,7 @@ eoi_parser:
|
||||
"marker parser used %d bytes (%d bits)\n",
|
||||
(get_bits_count(&s->gb) + 7) / 8, get_bits_count(&s->gb));
|
||||
}
|
||||
if (s->got_picture) {
|
||||
if (s->got_picture && s->cur_scan) {
|
||||
av_log(avctx, AV_LOG_WARNING, "EOI missing, emulating\n");
|
||||
goto eoi_parser;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,8 @@ int ff_mjpeg_decode_dqt(MJpegDecodeContext *s);
|
||||
int ff_mjpeg_decode_dht(MJpegDecodeContext *s);
|
||||
int ff_mjpeg_decode_sof(MJpegDecodeContext *s);
|
||||
int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
|
||||
const uint8_t *mb_bitmask, const AVFrame *reference);
|
||||
const uint8_t *mb_bitmask,int mb_bitmask_size,
|
||||
const AVFrame *reference);
|
||||
int ff_mjpeg_find_marker(MJpegDecodeContext *s,
|
||||
const uint8_t **buf_ptr, const uint8_t *buf_end,
|
||||
const uint8_t **unescaped_buf_ptr, int *unescaped_buf_size);
|
||||
|
||||
@@ -456,7 +456,7 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n)
|
||||
put_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]);
|
||||
}
|
||||
|
||||
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64])
|
||||
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64])
|
||||
{
|
||||
int i;
|
||||
if (s->chroma_format == CHROMA_444) {
|
||||
|
||||
@@ -56,6 +56,6 @@ void ff_mjpeg_encode_picture_trailer(MpegEncContext *s);
|
||||
void ff_mjpeg_encode_stuffing(MpegEncContext *s);
|
||||
void ff_mjpeg_encode_dc(MpegEncContext *s, int val,
|
||||
uint8_t *huff_size, uint16_t *huff_code);
|
||||
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64]);
|
||||
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]);
|
||||
|
||||
#endif /* AVCODEC_MJPEGENC_H */
|
||||
|
||||
+1
-1
@@ -818,7 +818,7 @@ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define MSB_MASK(bits) (-1u << bits)
|
||||
#define MSB_MASK(bits) (-1u << (bits))
|
||||
|
||||
/** Generate PCM samples using the prediction filters and residual values
|
||||
* read from the data stream, and update the filter state. */
|
||||
|
||||
@@ -1766,6 +1766,11 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
|
||||
s->quarter_sample= get_bits1(gb);
|
||||
else s->quarter_sample=0;
|
||||
|
||||
if (get_bits_left(gb) < 4) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "VOL Header truncated\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if(!get_bits1(gb)){
|
||||
int pos= get_bits_count(gb);
|
||||
int estimation_method= get_bits(gb, 2);
|
||||
|
||||
@@ -96,6 +96,7 @@ struct MpegEncContext;
|
||||
*/
|
||||
typedef struct Picture{
|
||||
struct AVFrame f;
|
||||
uint8_t avframe_padding[1024]; // hack to allow linking to a avutil with larger AVFrame
|
||||
ThreadFrame tf;
|
||||
|
||||
AVBufferRef *qscale_table_buf;
|
||||
|
||||
+5
-1
@@ -35,6 +35,7 @@
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "msrledec.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
|
||||
typedef struct MsrleContext {
|
||||
AVCodecContext *avctx;
|
||||
@@ -110,11 +111,14 @@ static int msrle_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
/* FIXME how to correctly detect RLE ??? */
|
||||
if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
|
||||
int linesize = (avctx->width * avctx->bits_per_coded_sample + 7) / 8;
|
||||
int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
|
||||
uint8_t *ptr = s->frame->data[0];
|
||||
uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
|
||||
int i, j;
|
||||
|
||||
if (linesize < 0)
|
||||
return linesize;
|
||||
|
||||
for (i = 0; i < avctx->height; i++) {
|
||||
if (avctx->bits_per_coded_sample == 4) {
|
||||
for (j = 0; j < avctx->width - 1; j += 2) {
|
||||
|
||||
@@ -84,8 +84,8 @@ void ff_mss34_gen_quant_mat(uint16_t *qmat, int quality, int luma)
|
||||
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)
|
||||
#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)
|
||||
{
|
||||
|
||||
+1
-1
@@ -364,7 +364,7 @@ static int get_value_cached(GetBitContext *gb, int vec_pos, uint8_t *vec,
|
||||
return prev[component];
|
||||
}
|
||||
|
||||
#define MKVAL(vals) (vals[0] | (vals[1] << 3) | (vals[2] << 6))
|
||||
#define MKVAL(vals) ((vals)[0] | ((vals)[1] << 3) | ((vals)[2] << 6))
|
||||
|
||||
/* Image mode - the hardest to comprehend MSS4 coding mode.
|
||||
*
|
||||
|
||||
@@ -295,11 +295,11 @@ static int mxpeg_decode_frame(AVCodecContext *avctx,
|
||||
AV_GET_BUFFER_FLAG_REF)) < 0)
|
||||
return ret;
|
||||
|
||||
ret = ff_mjpeg_decode_sos(jpg, s->mxm_bitmask, reference_ptr);
|
||||
ret = ff_mjpeg_decode_sos(jpg, s->mxm_bitmask, s->bitmask_size, reference_ptr);
|
||||
if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
|
||||
return ret;
|
||||
} else {
|
||||
ret = ff_mjpeg_decode_sos(jpg, NULL, NULL);
|
||||
ret = ff_mjpeg_decode_sos(jpg, NULL, 0, NULL);
|
||||
if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -902,8 +902,6 @@ void ff_thread_flush(AVCodecContext *avctx)
|
||||
if (fctx->prev_thread) {
|
||||
if (fctx->prev_thread != &fctx->threads[0])
|
||||
update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0);
|
||||
if (avctx->codec->flush)
|
||||
avctx->codec->flush(fctx->threads[0].avctx);
|
||||
}
|
||||
|
||||
fctx->next_decoding = fctx->next_finished = 0;
|
||||
@@ -916,6 +914,9 @@ void ff_thread_flush(AVCodecContext *avctx)
|
||||
av_frame_unref(p->frame);
|
||||
|
||||
release_delayed_buffers(p);
|
||||
|
||||
if (avctx->codec->flush)
|
||||
avctx->codec->flush(fctx->threads[0].avctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -318,7 +318,8 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer
|
||||
if(!sliced && !offset_dst)
|
||||
dst -= src_x;
|
||||
src_x=0;
|
||||
}else if(src_x + b_w > w){
|
||||
}
|
||||
if(src_x + b_w > w){
|
||||
b_w = w - src_x;
|
||||
}
|
||||
if(src_y<0){
|
||||
@@ -327,7 +328,8 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer
|
||||
if(!sliced && !offset_dst)
|
||||
dst -= src_y*dst_stride;
|
||||
src_y=0;
|
||||
}else if(src_y + b_h> h){
|
||||
}
|
||||
if(src_y + b_h> h){
|
||||
b_h = h - src_y;
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -720,11 +720,9 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (s->ti.bps != avctx->bits_per_raw_sample) {
|
||||
avctx->bits_per_raw_sample = s->ti.bps;
|
||||
if ((ret = set_bps_params(avctx)) < 0)
|
||||
return ret;
|
||||
}
|
||||
avctx->bits_per_raw_sample = s->ti.bps;
|
||||
if ((ret = set_bps_params(avctx)) < 0)
|
||||
return ret;
|
||||
if (s->ti.sample_rate != avctx->sample_rate) {
|
||||
avctx->sample_rate = s->ti.sample_rate;
|
||||
set_sample_rate_params(avctx);
|
||||
|
||||
@@ -79,6 +79,7 @@ static void free_geotags(TiffContext *const s)
|
||||
av_freep(&s->geotags[i].val);
|
||||
}
|
||||
av_freep(&s->geotags);
|
||||
s->geotag_count = 0;
|
||||
}
|
||||
|
||||
#define RET_GEOKEY(TYPE, array, element)\
|
||||
|
||||
+14
-8
@@ -733,8 +733,7 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
frame->width = FFMAX(avctx->width, FF_CEIL_RSHIFT(avctx->coded_width, avctx->lowres));
|
||||
frame->height = FFMAX(avctx->height, FF_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
|
||||
if (frame->format < 0)
|
||||
frame->format = avctx->pix_fmt;
|
||||
frame->format = avctx->pix_fmt;
|
||||
if (!frame->sample_aspect_ratio.num)
|
||||
frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
|
||||
if (av_frame_get_colorspace(frame) == AVCOL_SPC_UNSPECIFIED)
|
||||
@@ -781,6 +780,7 @@ int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame)
|
||||
typedef struct CompatReleaseBufPriv {
|
||||
AVCodecContext avctx;
|
||||
AVFrame frame;
|
||||
uint8_t avframe_padding[1024]; // hack to allow linking to a avutil with larger AVFrame
|
||||
} CompatReleaseBufPriv;
|
||||
|
||||
static void compat_free_buffer(void *opaque, uint8_t *data)
|
||||
@@ -1592,7 +1592,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
|
||||
const AVFrame *frame,
|
||||
int *got_packet_ptr)
|
||||
{
|
||||
AVFrame tmp;
|
||||
AVFrame *extended_frame = NULL;
|
||||
AVFrame *padded_frame = NULL;
|
||||
int ret;
|
||||
AVPacket user_pkt = *avpkt;
|
||||
@@ -1617,9 +1617,13 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
|
||||
}
|
||||
av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n");
|
||||
|
||||
tmp = *frame;
|
||||
tmp.extended_data = tmp.data;
|
||||
frame = &tmp;
|
||||
extended_frame = av_frame_alloc();
|
||||
if (!extended_frame)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
memcpy(extended_frame, frame, sizeof(AVFrame));
|
||||
extended_frame->extended_data = extended_frame->data;
|
||||
frame = extended_frame;
|
||||
}
|
||||
|
||||
/* check for valid frame size */
|
||||
@@ -1627,14 +1631,15 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
|
||||
if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
|
||||
if (frame->nb_samples > avctx->frame_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n");
|
||||
return AVERROR(EINVAL);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto end;
|
||||
}
|
||||
} else if (!(avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
|
||||
if (frame->nb_samples < avctx->frame_size &&
|
||||
!avctx->internal->last_audio_frame) {
|
||||
ret = pad_last_frame(avctx, &padded_frame, frame);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
frame = padded_frame;
|
||||
avctx->internal->last_audio_frame = 1;
|
||||
@@ -1706,6 +1711,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
|
||||
|
||||
end:
|
||||
av_frame_free(&padded_frame);
|
||||
av_free(extended_frame);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ static int build_huff(const uint8_t *src, VLC *vlc, int *fsym)
|
||||
code += 0x80000000u >> (he[i].len - 1);
|
||||
}
|
||||
|
||||
return ff_init_vlc_sparse(vlc, FFMIN(he[last].len, 10), last + 1,
|
||||
return ff_init_vlc_sparse(vlc, FFMIN(he[last].len, 11), last + 1,
|
||||
bits, sizeof(*bits), sizeof(*bits),
|
||||
codes, sizeof(*codes), sizeof(*codes),
|
||||
syms, sizeof(*syms), sizeof(*syms), 0);
|
||||
|
||||
@@ -456,7 +456,7 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
|
||||
* get the offset in bits and convert to bytes.
|
||||
*/
|
||||
offset += write_huff_codes(dst + sstart * width, c->slice_bits,
|
||||
width * (send - sstart), width,
|
||||
width * height + 4, width,
|
||||
send - sstart, he) >> 3;
|
||||
|
||||
slice_len = offset - slice_len;
|
||||
@@ -513,8 +513,7 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
|
||||
bytestream2_init_writer(&pb, dst, pkt->size);
|
||||
|
||||
av_fast_malloc(&c->slice_bits, &c->slice_bits_size,
|
||||
width * height + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
av_fast_padded_malloc(&c->slice_bits, &c->slice_bits_size, width * height + 4);
|
||||
|
||||
if (!c->slice_bits) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 2.\n");
|
||||
|
||||
+22
-8
@@ -627,10 +627,24 @@ static void rotate_luts(VC1Context *v)
|
||||
}
|
||||
}
|
||||
|
||||
static int read_bfraction(VC1Context *v, GetBitContext* gb) {
|
||||
int bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
|
||||
|
||||
if (bfraction_lut_index == 21 || bfraction_lut_index < 0) {
|
||||
av_log(v->s.avctx, AV_LOG_ERROR, "bfraction invalid\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
v->bfraction_lut_index = bfraction_lut_index;
|
||||
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
|
||||
{
|
||||
int pqindex, lowquant, status;
|
||||
|
||||
v->field_mode = 0;
|
||||
v->fcm = 0;
|
||||
if (v->finterpflag)
|
||||
v->interpfrm = get_bits1(gb);
|
||||
if (!v->s.avctx->codec)
|
||||
@@ -658,8 +672,8 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
|
||||
|
||||
v->bi_type = 0;
|
||||
if (v->s.pict_type == AV_PICTURE_TYPE_B) {
|
||||
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
|
||||
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
|
||||
if (read_bfraction(v, gb) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (v->bfraction == 0) {
|
||||
v->s.pict_type = AV_PICTURE_TYPE_BI;
|
||||
}
|
||||
@@ -937,8 +951,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
|
||||
v->refdist += get_unary(gb, 0, 16);
|
||||
}
|
||||
if ((v->s.pict_type == AV_PICTURE_TYPE_B) || (v->s.pict_type == AV_PICTURE_TYPE_BI)) {
|
||||
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
|
||||
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
|
||||
if (read_bfraction(v, gb) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
v->frfd = (v->bfraction * v->refdist) >> 8;
|
||||
v->brfd = v->refdist - v->frfd - 1;
|
||||
if (v->brfd < 0)
|
||||
@@ -950,8 +964,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
|
||||
if (v->finterpflag)
|
||||
v->interpfrm = get_bits1(gb);
|
||||
if (v->s.pict_type == AV_PICTURE_TYPE_B) {
|
||||
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
|
||||
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
|
||||
if (read_bfraction(v, gb) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (v->bfraction == 0) {
|
||||
v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */
|
||||
}
|
||||
@@ -1195,8 +1209,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
|
||||
break;
|
||||
case AV_PICTURE_TYPE_B:
|
||||
if (v->fcm == ILACE_FRAME) {
|
||||
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
|
||||
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
|
||||
if (read_bfraction(v, gb) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (v->bfraction == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
+7
-1
@@ -1917,9 +1917,10 @@ static void vc1_interp_mc(VC1Context *v)
|
||||
uvmx = (mx + ((mx & 3) == 3)) >> 1;
|
||||
uvmy = (my + ((my & 3) == 3)) >> 1;
|
||||
if (v->field_mode) {
|
||||
if (v->cur_field_type != v->ref_field_type[1])
|
||||
if (v->cur_field_type != v->ref_field_type[1]) {
|
||||
my = my - 2 + 4 * v->cur_field_type;
|
||||
uvmy = uvmy - 2 + 4 * v->cur_field_type;
|
||||
}
|
||||
}
|
||||
if (v->fastuvmc) {
|
||||
uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
|
||||
@@ -4342,6 +4343,10 @@ static void vc1_decode_b_mb_intfi(VC1Context *v)
|
||||
if (bmvtype == BMV_TYPE_DIRECT) {
|
||||
dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
|
||||
dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
|
||||
if (!s->next_picture_ptr->field_picture) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Mixed field/frame direct mode not supported\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
vc1_pred_b_mv_intfi(v, 0, dmv_x, dmv_y, 1, pred_flag);
|
||||
vc1_b_mc(v, dmv_x, dmv_y, (bmvtype == BMV_TYPE_DIRECT), bmvtype);
|
||||
@@ -6028,6 +6033,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
goto err;
|
||||
}
|
||||
|
||||
v->s.current_picture_ptr->field_picture = v->field_mode;
|
||||
v->s.current_picture_ptr->f.interlaced_frame = (v->fcm != PROGRESSIVE);
|
||||
v->s.current_picture_ptr->f.top_field_first = v->tff;
|
||||
|
||||
|
||||
@@ -291,6 +291,11 @@ static int decode_hextile(VmncContext *c, uint8_t* dst, GetByteContext *gb,
|
||||
fg = vmnc_get_pixel(gb, bpp, c->bigendian);
|
||||
xy = bytestream2_get_byte(gb);
|
||||
wh = bytestream2_get_byte(gb);
|
||||
if ( (xy >> 4) + (wh >> 4) + 1 > w - i
|
||||
|| (xy & 0xF) + (wh & 0xF)+1 > h - j) {
|
||||
av_log(c->avctx, AV_LOG_ERROR, "Rectangle outside picture\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
paint_rect(dst2, xy >> 4, xy & 0xF,
|
||||
(wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
|
||||
}
|
||||
|
||||
+26
-11
@@ -151,7 +151,7 @@ typedef struct vorbis_context_s {
|
||||
uint8_t mode_count;
|
||||
vorbis_mode *modes;
|
||||
uint8_t mode_number; // mode number for the current packet
|
||||
uint8_t previous_window;
|
||||
int8_t previous_window;
|
||||
float *channel_residues;
|
||||
float *saved;
|
||||
} vorbis_context;
|
||||
@@ -701,8 +701,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
|
||||
res_setup->partition_size = get_bits(gb, 24) + 1;
|
||||
/* Validations to prevent a buffer overflow later. */
|
||||
if (res_setup->begin>res_setup->end ||
|
||||
res_setup->end > (res_setup->type == 2 ? vc->audio_channels : 1) * vc->blocksize[1] / 2 ||
|
||||
(res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) {
|
||||
(res_setup->end-res_setup->begin) / res_setup->partition_size > FFMIN(V_MAX_PARTITIONS, 65535)) {
|
||||
av_log(vc->avctx, AV_LOG_ERROR,
|
||||
"partition out of bounds: type, begin, end, size, blocksize: %"PRIu16", %"PRIu32", %"PRIu32", %u, %"PRIu32"\n",
|
||||
res_setup->type, res_setup->begin, res_setup->end,
|
||||
@@ -989,7 +988,7 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
|
||||
if (!vc->channel_residues || !vc->saved)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
vc->previous_window = 0;
|
||||
vc->previous_window = -1;
|
||||
|
||||
ff_mdct_init(&vc->mdct[0], bl0, 1, -1.0);
|
||||
ff_mdct_init(&vc->mdct[1], bl1, 1, -1.0);
|
||||
@@ -1372,6 +1371,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
unsigned pass, ch_used, i, j, k, l;
|
||||
unsigned max_output = (ch - 1) * vlen;
|
||||
int ptns_to_read = vr->ptns_to_read;
|
||||
int libvorbis_bug = 0;
|
||||
|
||||
if (vr_type == 2) {
|
||||
for (j = 1; j < ch; ++j)
|
||||
@@ -1386,8 +1386,13 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
}
|
||||
|
||||
if (max_output > ch_left * vlen) {
|
||||
av_log(vc->avctx, AV_LOG_ERROR, "Insufficient output buffer\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (max_output <= ch_left * vlen + vr->partition_size*ch_used/ch) {
|
||||
ptns_to_read--;
|
||||
libvorbis_bug = 1;
|
||||
} else {
|
||||
av_log(vc->avctx, AV_LOG_ERROR, "Insufficient output buffer\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
av_dlog(NULL, " residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
|
||||
@@ -1496,6 +1501,14 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
voffset += vr->partition_size;
|
||||
}
|
||||
}
|
||||
if (libvorbis_bug && !pass) {
|
||||
for (j = 0; j < ch_used; ++j) {
|
||||
if (!do_not_decode[j]) {
|
||||
get_vlc2(&vc->gb, vc->codebooks[vr->classbook].vlc.table,
|
||||
vc->codebooks[vr->classbook].nb_bits, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1548,7 +1561,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
|
||||
{
|
||||
GetBitContext *gb = &vc->gb;
|
||||
FFTContext *mdct;
|
||||
unsigned previous_window = vc->previous_window;
|
||||
int previous_window = vc->previous_window;
|
||||
unsigned mode_number, blockflag, blocksize;
|
||||
int i, j;
|
||||
uint8_t no_residue[255];
|
||||
@@ -1581,9 +1594,11 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
|
||||
blocksize = vc->blocksize[blockflag];
|
||||
vlen = blocksize / 2;
|
||||
if (blockflag) {
|
||||
previous_window = get_bits(gb, 1);
|
||||
skip_bits1(gb); // next_window
|
||||
}
|
||||
int code = get_bits(gb, 2);
|
||||
if (previous_window < 0)
|
||||
previous_window = code>>1;
|
||||
} else if (previous_window < 0)
|
||||
previous_window = 0;
|
||||
|
||||
memset(ch_res_ptr, 0, sizeof(float) * vc->audio_channels * vlen); //FIXME can this be removed ?
|
||||
for (i = 0; i < vc->audio_channels; ++i)
|
||||
@@ -1812,7 +1827,7 @@ static av_cold void vorbis_decode_flush(AVCodecContext *avctx)
|
||||
memset(vc->saved, 0, (vc->blocksize[1] / 4) * vc->audio_channels *
|
||||
sizeof(*vc->saved));
|
||||
}
|
||||
vc->previous_window = 0;
|
||||
vc->previous_window = -1;
|
||||
}
|
||||
|
||||
AVCodec ff_vorbis_decoder = {
|
||||
|
||||
+3
-3
@@ -386,9 +386,9 @@ int ff_wma_end(AVCodecContext *avctx)
|
||||
}
|
||||
for (i = 0; i < 2; i++) {
|
||||
ff_free_vlc(&s->coef_vlc[i]);
|
||||
av_free(s->run_table[i]);
|
||||
av_free(s->level_table[i]);
|
||||
av_free(s->int_table[i]);
|
||||
av_freep(&s->run_table[i]);
|
||||
av_freep(&s->level_table[i]);
|
||||
av_freep(&s->int_table[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -127,8 +127,8 @@ typedef struct WmallDecodeCtx {
|
||||
|
||||
int8_t mclms_order;
|
||||
int8_t mclms_scaling;
|
||||
int16_t mclms_coeffs[128];
|
||||
int16_t mclms_coeffs_cur[4];
|
||||
int16_t mclms_coeffs[WMALL_MAX_CHANNELS * WMALL_MAX_CHANNELS * 32];
|
||||
int16_t mclms_coeffs_cur[WMALL_MAX_CHANNELS * WMALL_MAX_CHANNELS];
|
||||
int16_t mclms_prevvalues[WMALL_MAX_CHANNELS * 2 * 32];
|
||||
int16_t mclms_updates[WMALL_MAX_CHANNELS * 2 * 32];
|
||||
int mclms_recent;
|
||||
|
||||
@@ -343,7 +343,7 @@ DECLARE_ASM_CONST(16, int32_t, walkenIdctRounders)[] = {
|
||||
"movdqa %%xmm6, 4*16("dct") \n\t" \
|
||||
"movdqa "SREG2", 7*16("dct") \n\t"
|
||||
|
||||
inline void ff_idct_xvid_sse2(short *block)
|
||||
av_extern_inline void ff_idct_xvid_sse2(short *block)
|
||||
{
|
||||
__asm__ volatile(
|
||||
"movq "MANGLE(m127)", %%mm0 \n\t"
|
||||
|
||||
@@ -216,7 +216,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
|
||||
"psubusw "MM"1, "MM"4 \n\t"
|
||||
"packuswb "MM"4, "MM"4 \n\t"
|
||||
#if COMPILE_TEMPLATE_SSE2
|
||||
"packuswb "MM"4, "MM"4 \n\t"
|
||||
"packsswb "MM"4, "MM"4 \n\t"
|
||||
#endif
|
||||
"movd "MM"4, %0 \n\t" // *overflow
|
||||
: "=g" (*overflow)
|
||||
|
||||
@@ -1058,11 +1058,11 @@ static int push_samples(ATempoContext *atempo,
|
||||
outlink->time_base);
|
||||
|
||||
ret = ff_filter_frame(outlink, atempo->dst_buffer);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
atempo->dst_buffer = NULL;
|
||||
atempo->dst = NULL;
|
||||
atempo->dst_end = NULL;
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
atempo->nsamples_out += n_out;
|
||||
return 0;
|
||||
|
||||
@@ -57,7 +57,7 @@ int ff_dualinput_init(AVFilterContext *ctx, FFDualInputContext *s)
|
||||
in[1].after = EXT_INFINITY;
|
||||
|
||||
if (s->shortest)
|
||||
in[1].after = EXT_STOP;
|
||||
in[0].after = in[1].after = EXT_STOP;
|
||||
if (!s->repeatlast) {
|
||||
in[0].after = EXT_STOP;
|
||||
in[1].sync = 0;
|
||||
|
||||
@@ -279,7 +279,7 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame)
|
||||
p2 += 8 * linesize;
|
||||
}
|
||||
emms_c();
|
||||
mafd = nb_sad ? sad / nb_sad : 0;
|
||||
mafd = nb_sad ? (double)sad / nb_sad : 0;
|
||||
diff = fabs(mafd - select->prev_mafd);
|
||||
ret = av_clipf(FFMIN(mafd, diff) / 100., 0, 1);
|
||||
select->prev_mafd = mafd;
|
||||
|
||||
@@ -38,7 +38,7 @@ static void print_formats(AVFilterContext *filter_ctx)
|
||||
for (j = 0; j < fmts->nb_formats; j++) \
|
||||
if(av_get_pix_fmt_name(fmts->formats[j])) \
|
||||
printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
|
||||
i, filter_ctx->filter->inout##puts[i].name, \
|
||||
i, filter_ctx->inout##put_pads[i].name, \
|
||||
av_get_pix_fmt_name(fmts->formats[j])); \
|
||||
} else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \
|
||||
AVFilterFormats *fmts; \
|
||||
@@ -47,7 +47,7 @@ static void print_formats(AVFilterContext *filter_ctx)
|
||||
fmts = filter_ctx->inout##puts[i]->outin##_formats; \
|
||||
for (j = 0; j < fmts->nb_formats; j++) \
|
||||
printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
|
||||
i, filter_ctx->filter->inout##puts[i].name, \
|
||||
i, filter_ctx->inout##put_pads[i].name, \
|
||||
av_get_sample_fmt_name(fmts->formats[j])); \
|
||||
\
|
||||
layouts = filter_ctx->inout##puts[i]->outin##_channel_layouts; \
|
||||
@@ -56,7 +56,7 @@ static void print_formats(AVFilterContext *filter_ctx)
|
||||
av_get_channel_layout_string(buf, sizeof(buf), -1, \
|
||||
layouts->channel_layouts[j]); \
|
||||
printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \
|
||||
i, filter_ctx->filter->inout##puts[i].name, buf); \
|
||||
i, filter_ctx->inout##put_pads[i].name, buf); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
@@ -113,12 +113,12 @@ int main(int argc, char **argv)
|
||||
/* create a link for each of the input pads */
|
||||
for (i = 0; i < filter_ctx->nb_inputs; i++) {
|
||||
AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
|
||||
link->type = filter_ctx->filter->inputs[i].type;
|
||||
link->type = filter_ctx->input_pads[i].type;
|
||||
filter_ctx->inputs[i] = link;
|
||||
}
|
||||
for (i = 0; i < filter_ctx->nb_outputs; i++) {
|
||||
AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
|
||||
link->type = filter_ctx->filter->outputs[i].type;
|
||||
link->type = filter_ctx->output_pads[i].type;
|
||||
filter_ctx->outputs[i] = link;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,10 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
|
||||
{
|
||||
char *format;
|
||||
char layout[64];
|
||||
AVBPrint dummy_buffer = { 0 };
|
||||
|
||||
if (!buf)
|
||||
buf = &(AVBPrint){ 0 }; /* dummy buffer */
|
||||
buf = &dummy_buffer;
|
||||
switch (link->type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
format = av_x_if_null(av_get_pix_fmt_name(link->format), "?");
|
||||
|
||||
@@ -306,8 +306,8 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
|
||||
//av_log(NULL, AV_LOG_ERROR, "\n");
|
||||
}
|
||||
|
||||
p_x = (center_x - width / 2);
|
||||
p_y = (center_y - height / 2);
|
||||
p_x = (center_x - width / 2.0);
|
||||
p_y = (center_y - height / 2.0);
|
||||
t->vector.x += (cos(t->angle)-1)*p_x - sin(t->angle)*p_y;
|
||||
t->vector.y += sin(t->angle)*p_x + (cos(t->angle)-1)*p_y;
|
||||
|
||||
|
||||
@@ -235,6 +235,8 @@ static int alloc_buffer(PullupContext *s, PullupBuffer *b)
|
||||
for (i = 0; i < s->nb_planes; i++) {
|
||||
b->planes[i] = av_malloc(s->planeheight[i] * s->planewidth[i]);
|
||||
}
|
||||
if (s->nb_planes == 1)
|
||||
b->planes[1] = av_malloc(4*256);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ static int aiff_read_header(AVFormatContext *s)
|
||||
break;
|
||||
case MKTAG('I', 'D', '3', ' '):
|
||||
position = avio_tell(pb);
|
||||
ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
|
||||
ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, size);
|
||||
if (id3v2_extra_meta)
|
||||
if ((ret = ff_id3v2_parse_apic(s, &id3v2_extra_meta)) < 0) {
|
||||
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
|
||||
@@ -345,10 +345,16 @@ static int aiff_read_packet(AVFormatContext *s,
|
||||
return AVERROR_EOF;
|
||||
|
||||
/* Now for that packet */
|
||||
if (st->codec->block_align >= 17) // GSM, QCLP, IMA4
|
||||
switch (st->codec->codec_id) {
|
||||
case AV_CODEC_ID_ADPCM_IMA_QT:
|
||||
case AV_CODEC_ID_GSM:
|
||||
case AV_CODEC_ID_QDM2:
|
||||
case AV_CODEC_ID_QCELP:
|
||||
size = st->codec->block_align;
|
||||
else
|
||||
break;
|
||||
default:
|
||||
size = (MAX_SIZE / st->codec->block_align) * st->codec->block_align;
|
||||
}
|
||||
size = FFMIN(max_size, size);
|
||||
res = av_get_packet(s->pb, pkt, size);
|
||||
if (res < 0)
|
||||
|
||||
+3
-1
@@ -411,8 +411,10 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||
AV_WL32(pkt->data , nblocks);
|
||||
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
|
||||
ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
av_free_packet(pkt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pkt->pts = ape->frames[ape->currentframe].pts;
|
||||
pkt->stream_index = 0;
|
||||
|
||||
@@ -266,7 +266,7 @@ static void get_id3_tag(AVFormatContext *s, int len)
|
||||
{
|
||||
ID3v2ExtraMeta *id3v2_extra_meta = NULL;
|
||||
|
||||
ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
|
||||
ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, len);
|
||||
if (id3v2_extra_meta)
|
||||
ff_id3v2_parse_apic(s, &id3v2_extra_meta);
|
||||
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
|
||||
@@ -370,7 +370,8 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
|
||||
|
||||
if (!(asf->hdr.flags & 0x01)) { // if we aren't streaming...
|
||||
int64_t fsize = avio_size(pb);
|
||||
if (fsize <= 0 || (int64_t)asf->hdr.file_size <= 0 || FFABS(fsize - (int64_t)asf->hdr.file_size) < 10000)
|
||||
if (fsize <= 0 || (int64_t)asf->hdr.file_size <= 0 ||
|
||||
FFABS(fsize - (int64_t)asf->hdr.file_size) / (float)FFMIN(fsize, asf->hdr.file_size) < 0.05)
|
||||
st->duration = asf->hdr.play_time /
|
||||
(10000000 / 1000) - start_time;
|
||||
}
|
||||
|
||||
+58
-6
@@ -348,6 +348,7 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
|
||||
uint16_t size = avio_rl16(s->pb);
|
||||
const char *name = NULL;
|
||||
char buffer[64] = { 0 };
|
||||
size = FFMIN(size, tag_end - avio_tell(s->pb));
|
||||
size -= avio_read(s->pb, buffer,
|
||||
FFMIN(size, sizeof(buffer) - 1));
|
||||
switch (tag) {
|
||||
@@ -376,6 +377,46 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
|
||||
}
|
||||
}
|
||||
|
||||
static int calculate_bitrate(AVFormatContext *s)
|
||||
{
|
||||
AVIContext *avi = s->priv_data;
|
||||
int i, j;
|
||||
int64_t lensum = 0;
|
||||
int64_t maxpos = 0;
|
||||
|
||||
for (i = 0; i<s->nb_streams; i++) {
|
||||
int64_t len = 0;
|
||||
AVStream *st = s->streams[i];
|
||||
|
||||
if (!st->nb_index_entries)
|
||||
continue;
|
||||
|
||||
for (j = 0; j < st->nb_index_entries; j++)
|
||||
len += st->index_entries[j].size;
|
||||
maxpos = FFMAX(maxpos, st->index_entries[j-1].pos);
|
||||
lensum += len;
|
||||
}
|
||||
if (maxpos < avi->io_fsize*9/10) // index doesnt cover the whole file
|
||||
return 0;
|
||||
if (lensum*9/10 > maxpos || lensum < maxpos*9/10) // frame sum and filesize mismatch
|
||||
return 0;
|
||||
|
||||
for (i = 0; i<s->nb_streams; i++) {
|
||||
int64_t len = 0;
|
||||
AVStream *st = s->streams[i];
|
||||
int64_t duration;
|
||||
|
||||
for (j = 0; j < st->nb_index_entries; j++)
|
||||
len += st->index_entries[j].size;
|
||||
|
||||
if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)
|
||||
continue;
|
||||
duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;
|
||||
st->codec->bit_rate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int avi_read_header(AVFormatContext *s)
|
||||
{
|
||||
AVIContext *avi = s->priv_data;
|
||||
@@ -860,6 +901,7 @@ fail:
|
||||
|
||||
if (!avi->index_loaded && pb->seekable)
|
||||
avi_load_index(s);
|
||||
calculate_bitrate(s);
|
||||
avi->index_loaded |= 1;
|
||||
avi->non_interleaved |= guess_ni_flag(s) | (s->flags & AVFMT_FLAG_SORT_DTS);
|
||||
|
||||
@@ -1312,7 +1354,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
AVIndexEntry *e;
|
||||
int index;
|
||||
|
||||
index = av_index_search_timestamp(st, ast->frame_offset, 0);
|
||||
index = av_index_search_timestamp(st, ast->frame_offset, AVSEEK_FLAG_ANY);
|
||||
e = &st->index_entries[index];
|
||||
|
||||
if (index >= 0 && e->timestamp == ast->frame_offset) {
|
||||
@@ -1490,6 +1532,7 @@ static int guess_ni_flag(AVFormatContext *s)
|
||||
return 0;
|
||||
for (min_pos=pos=0; min_pos!=INT64_MAX; pos= min_pos+1LU) {
|
||||
int64_t max_dts = INT64_MIN/2, min_dts= INT64_MAX/2;
|
||||
int64_t max_buffer = 0;
|
||||
min_pos = INT64_MAX;
|
||||
|
||||
for (i=0; i<s->nb_streams; i++) {
|
||||
@@ -1502,10 +1545,20 @@ static int guess_ni_flag(AVFormatContext *s)
|
||||
min_dts = FFMIN(min_dts, av_rescale_q(st->index_entries[idx[i]].timestamp/FFMAX(ast->sample_size, 1), st->time_base, AV_TIME_BASE_Q));
|
||||
min_pos = FFMIN(min_pos, st->index_entries[idx[i]].pos);
|
||||
}
|
||||
if (idx[i])
|
||||
max_dts = FFMAX(max_dts, av_rescale_q(st->index_entries[idx[i]-1].timestamp/FFMAX(ast->sample_size, 1), st->time_base, AV_TIME_BASE_Q));
|
||||
}
|
||||
if (max_dts - min_dts > 2*AV_TIME_BASE) {
|
||||
for (i=0; i<s->nb_streams; i++) {
|
||||
AVStream *st = s->streams[i];
|
||||
AVIStream *ast = st->priv_data;
|
||||
|
||||
if (idx[i] && min_dts != INT64_MAX/2) {
|
||||
int64_t dts = av_rescale_q(st->index_entries[idx[i]-1].timestamp/FFMAX(ast->sample_size, 1), st->time_base, AV_TIME_BASE_Q);
|
||||
max_dts = FFMAX(max_dts, dts);
|
||||
max_buffer = FFMAX(max_buffer, av_rescale(dts - min_dts, st->codec->bit_rate, AV_TIME_BASE));
|
||||
}
|
||||
}
|
||||
if (max_dts - min_dts > 2*AV_TIME_BASE ||
|
||||
max_buffer > 1024 * 1024 * 8 *8
|
||||
) {
|
||||
av_free(idx);
|
||||
return 1;
|
||||
}
|
||||
@@ -1647,8 +1700,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
|
||||
continue;
|
||||
|
||||
// av_assert1(st2->codec->block_align);
|
||||
av_assert0((int64_t)st2->time_base.num * ast2->rate ==
|
||||
(int64_t)st2->time_base.den * ast2->scale);
|
||||
av_assert0(fabs(av_q2d(st2->time_base) - ast2->scale / (double)ast2->rate) < av_q2d(st2->time_base) * 0.00000001);
|
||||
index = av_index_search_timestamp(st2,
|
||||
av_rescale_q(timestamp,
|
||||
st->time_base,
|
||||
|
||||
+4
-2
@@ -79,6 +79,7 @@ static int read_header(AVFormatContext *s)
|
||||
uint32_t pos, next_pos;
|
||||
uint16_t flags;
|
||||
int keyframe;
|
||||
int ret;
|
||||
|
||||
vst = avformat_new_stream(s, NULL);
|
||||
if (!vst)
|
||||
@@ -177,8 +178,9 @@ static int read_header(AVFormatContext *s)
|
||||
av_log(s, AV_LOG_ERROR, "invalid frame index table\n");
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
av_add_index_entry(vst, pos, i, next_pos - pos, 0,
|
||||
keyframe ? AVINDEX_KEYFRAME : 0);
|
||||
if ((ret = av_add_index_entry(vst, pos, i, next_pos - pos, 0,
|
||||
keyframe ? AVINDEX_KEYFRAME : 0)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
avio_skip(pb, 4);
|
||||
|
||||
@@ -61,7 +61,7 @@ static int cavsvideo_probe(AVProbeData *p)
|
||||
}
|
||||
}
|
||||
if(seq && seq*9<=pic*10)
|
||||
return AVPROBE_SCORE_EXTENSION;
|
||||
return AVPROBE_SCORE_EXTENSION+1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,9 +107,10 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
if (!(data = av_buffer_alloc(len))) {
|
||||
if (!(data = av_buffer_alloc(len + FF_INPUT_BUFFER_PADDING_SIZE))) {
|
||||
RETURN_ERROR(AVERROR(ENOMEM));
|
||||
}
|
||||
memset(data->data + len, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (avio_read(pb, data->data, len) != len) {
|
||||
av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n");
|
||||
if (s->error_recognition & AV_EF_EXPLODE)
|
||||
|
||||
@@ -938,6 +938,10 @@ retry_duration:
|
||||
flv->wrong_dts = 1;
|
||||
av_log(s, AV_LOG_WARNING,
|
||||
"negative cts, previous timestamps might be wrong\n");
|
||||
} else if (FFABS(dts - pts) > 1000*60*15) {
|
||||
av_log(s, AV_LOG_WARNING,
|
||||
"invalid timestamps %"PRId64" %"PRId64"\n", dts, pts);
|
||||
dts = pts = AV_NOPTS_VALUE;
|
||||
}
|
||||
if (flv->wrong_dts)
|
||||
dts = AV_NOPTS_VALUE;
|
||||
|
||||
@@ -222,6 +222,18 @@ static int flv_write_header(AVFormatContext *s)
|
||||
avcodec_get_name(enc->codec_id), i);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (enc->codec_id == AV_CODEC_ID_MPEG4 ||
|
||||
enc->codec_id == AV_CODEC_ID_H263) {
|
||||
int error = enc->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL;
|
||||
av_log(s, error ? AV_LOG_ERROR : AV_LOG_WARNING,
|
||||
"Codec %s is not supported in the official FLV specification,\n", avcodec_get_name(enc->codec_id));
|
||||
|
||||
if (error) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"use vstrict=-1 / -strict -1 to use it anyway.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
if (audio_enc) {
|
||||
|
||||
@@ -35,7 +35,7 @@ static int h263_probe(AVProbeData *p)
|
||||
for(i=0; i<p->buf_size; i++){
|
||||
code = (code<<8) + p->buf[i];
|
||||
if ((code & 0xfffffc0000) == 0x800000) {
|
||||
src_fmt= (code>>2)&3;
|
||||
src_fmt= (code>>2)&7;
|
||||
if( src_fmt != last_src_fmt
|
||||
&& last_src_fmt>0 && last_src_fmt<6
|
||||
&& src_fmt<6)
|
||||
|
||||
+13
-2
@@ -815,16 +815,25 @@ error:
|
||||
}
|
||||
|
||||
void ff_id3v2_read(AVFormatContext *s, const char *magic,
|
||||
ID3v2ExtraMeta **extra_meta)
|
||||
ID3v2ExtraMeta **extra_meta, unsigned int max_search_size)
|
||||
{
|
||||
int len, ret;
|
||||
uint8_t buf[ID3v2_HEADER_SIZE];
|
||||
int found_header;
|
||||
int64_t off;
|
||||
int64_t start, off;
|
||||
|
||||
if (max_search_size && max_search_size < ID3v2_HEADER_SIZE)
|
||||
return;
|
||||
|
||||
start = avio_tell(s->pb);
|
||||
do {
|
||||
/* save the current offset in case there's nothing to read/skip */
|
||||
off = avio_tell(s->pb);
|
||||
if (max_search_size && off - start >= max_search_size - ID3v2_HEADER_SIZE) {
|
||||
avio_seek(s->pb, off, SEEK_SET);
|
||||
break;
|
||||
}
|
||||
|
||||
ret = avio_read(s->pb, buf, ID3v2_HEADER_SIZE);
|
||||
if (ret != ID3v2_HEADER_SIZE) {
|
||||
avio_seek(s->pb, off, SEEK_SET);
|
||||
@@ -860,6 +869,8 @@ void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
|
||||
av_freep(¤t);
|
||||
current = next;
|
||||
}
|
||||
|
||||
*extra_meta = NULL;
|
||||
}
|
||||
|
||||
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
|
||||
|
||||
+3
-1
@@ -92,8 +92,10 @@ int ff_id3v2_tag_len(const uint8_t *buf);
|
||||
* Read an ID3v2 tag, including supported extra metadata
|
||||
* @param extra_meta If not NULL, extra metadata is parsed into a list of
|
||||
* ID3v2ExtraMeta structs and *extra_meta points to the head of the list
|
||||
* @param[opt] max_search_search restrict ID3 magic number search (bytes from start)
|
||||
*/
|
||||
void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta);
|
||||
void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta,
|
||||
unsigned int max_search_size);
|
||||
|
||||
/**
|
||||
* Initialize an ID3v2 tag.
|
||||
|
||||
@@ -159,7 +159,7 @@ static int64_t libssh_seek(URLContext *h, int64_t pos, int whence)
|
||||
newpos = pos;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
newpos = sftp_tell64(s->file);
|
||||
newpos = sftp_tell64(s->file) + pos;
|
||||
break;
|
||||
case SEEK_END:
|
||||
newpos = s->filesize + pos;
|
||||
|
||||
@@ -1723,8 +1723,12 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
} else if (!strcmp(track->codec_id, "V_QUICKTIME")
|
||||
&& (track->codec_priv.size >= 86)
|
||||
&& (track->codec_priv.data != NULL)) {
|
||||
fourcc = AV_RL32(track->codec_priv.data);
|
||||
fourcc = AV_RL32(track->codec_priv.data + 4);
|
||||
codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
|
||||
if (ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(track->codec_priv.data))) {
|
||||
fourcc = AV_RL32(track->codec_priv.data);
|
||||
codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
|
||||
}
|
||||
} else if (codec_id == AV_CODEC_ID_PCM_S16BE) {
|
||||
switch (track->audio.bitdepth) {
|
||||
case 8: codec_id = AV_CODEC_ID_PCM_U8; break;
|
||||
@@ -1834,7 +1838,7 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
avpriv_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */
|
||||
|
||||
st->codec->codec_id = codec_id;
|
||||
st->start_time = 0;
|
||||
|
||||
if (strcmp(track->language, "und"))
|
||||
av_dict_set(&st->metadata, "language", track->language, 0);
|
||||
av_dict_set(&st->metadata, "title", track->name, 0);
|
||||
@@ -1906,6 +1910,7 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
st->codec->sample_rate = track->audio.out_samplerate;
|
||||
st->codec->channels = track->audio.channels;
|
||||
if (!st->codec->bits_per_coded_sample)
|
||||
st->codec->bits_per_coded_sample = track->audio.bitdepth;
|
||||
if (st->codec->codec_id != AV_CODEC_ID_AAC)
|
||||
st->need_parsing = AVSTREAM_PARSE_HEADERS;
|
||||
|
||||
@@ -546,8 +546,18 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo
|
||||
if (qt_id) {
|
||||
if (!codec->codec_tag)
|
||||
codec->codec_tag = ff_codec_get_tag(ff_codec_movvideo_tags, codec->codec_id);
|
||||
if (codec->extradata_size)
|
||||
if (codec->extradata_size) {
|
||||
if ( ff_codec_get_id(ff_codec_movvideo_tags, codec->codec_tag) == codec->codec_id
|
||||
&& ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(codec->extradata+4)) != codec->codec_id
|
||||
) {
|
||||
int i;
|
||||
avio_wb32(dyn_cp, 0x5a + codec->extradata_size);
|
||||
avio_wl32(dyn_cp, codec->codec_tag);
|
||||
for(i=0; i<0x5a-8; i++)
|
||||
avio_w8(dyn_cp, 0);
|
||||
}
|
||||
avio_write(dyn_cp, codec->extradata, codec->extradata_size);
|
||||
}
|
||||
} else {
|
||||
if (!codec->codec_tag)
|
||||
codec->codec_tag = ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id);
|
||||
@@ -612,7 +622,7 @@ static int mkv_write_tracks(AVFormatContext *s)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!bit_depth)
|
||||
if (!bit_depth && codec->codec_id != AV_CODEC_ID_ADPCM_G726)
|
||||
bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3;
|
||||
if (!bit_depth)
|
||||
bit_depth = codec->bits_per_coded_sample;
|
||||
@@ -1047,7 +1057,7 @@ static int mkv_write_header(AVFormatContext *s)
|
||||
AVIOContext *pb = s->pb;
|
||||
ebml_master ebml_header, segment_info;
|
||||
AVDictionaryEntry *tag;
|
||||
int ret, i;
|
||||
int ret, i, version = 2;
|
||||
|
||||
if (!strcmp(s->oformat->name, "webm")) mkv->mode = MODE_WEBM;
|
||||
else mkv->mode = MODE_MATROSKAv2;
|
||||
@@ -1055,7 +1065,12 @@ static int mkv_write_header(AVFormatContext *s)
|
||||
if (s->avoid_negative_ts < 0)
|
||||
s->avoid_negative_ts = 1;
|
||||
|
||||
for (i = 0; i < s->nb_streams; i++)
|
||||
if (mkv->mode != MODE_WEBM ||
|
||||
av_dict_get(s->metadata, "stereo_mode", NULL, 0) ||
|
||||
av_dict_get(s->metadata, "alpha_mode", NULL, 0))
|
||||
version = 4;
|
||||
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
if (s->streams[i]->codec->codec_id == AV_CODEC_ID_ATRAC3 ||
|
||||
s->streams[i]->codec->codec_id == AV_CODEC_ID_COOK ||
|
||||
s->streams[i]->codec->codec_id == AV_CODEC_ID_RA_288 ||
|
||||
@@ -1067,6 +1082,11 @@ static int mkv_write_header(AVFormatContext *s)
|
||||
avcodec_get_name(s->streams[i]->codec->codec_id));
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
if (s->streams[i]->codec->codec_id == AV_CODEC_ID_OPUS ||
|
||||
av_dict_get(s->streams[i]->metadata, "stereo_mode", NULL, 0) ||
|
||||
av_dict_get(s->streams[i]->metadata, "alpha_mode", NULL, 0))
|
||||
version = 4;
|
||||
}
|
||||
|
||||
mkv->tracks = av_mallocz(s->nb_streams * sizeof(*mkv->tracks));
|
||||
if (!mkv->tracks)
|
||||
@@ -1078,7 +1098,7 @@ static int mkv_write_header(AVFormatContext *s)
|
||||
put_ebml_uint (pb, EBML_ID_EBMLMAXIDLENGTH , 4);
|
||||
put_ebml_uint (pb, EBML_ID_EBMLMAXSIZELENGTH , 8);
|
||||
put_ebml_string (pb, EBML_ID_DOCTYPE , s->oformat->name);
|
||||
put_ebml_uint (pb, EBML_ID_DOCTYPEVERSION , 4);
|
||||
put_ebml_uint (pb, EBML_ID_DOCTYPEVERSION , version);
|
||||
put_ebml_uint (pb, EBML_ID_DOCTYPEREADVERSION , 2);
|
||||
end_ebml_master(pb, ebml_header);
|
||||
|
||||
|
||||
+6
-1
@@ -1781,7 +1781,7 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
if (!entries)
|
||||
{
|
||||
sc->keyframe_absent = 1;
|
||||
if (!st->need_parsing)
|
||||
if (!st->need_parsing && st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
st->need_parsing = AVSTREAM_PARSE_HEADERS;
|
||||
return 0;
|
||||
}
|
||||
@@ -2144,6 +2144,11 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
|
||||
rap_group_index++;
|
||||
}
|
||||
}
|
||||
if (sc->keyframe_absent
|
||||
&& !sc->stps_count
|
||||
&& !rap_group_present
|
||||
&& st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
keyframe = 1;
|
||||
if (keyframe)
|
||||
distance = 0;
|
||||
sample_size = sc->stsz_sample_size > 0 ? sc->stsz_sample_size : sc->sample_sizes[current_sample];
|
||||
|
||||
@@ -899,11 +899,14 @@ static AVRational find_fps(AVFormatContext *s, AVStream *st)
|
||||
|
||||
static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||
{
|
||||
int tag = MKTAG('m', '2', 'v', '1'); //fallback tag
|
||||
int tag = track->enc->codec_tag;
|
||||
int interlaced = track->enc->field_order > AV_FIELD_PROGRESSIVE;
|
||||
AVStream *st = track->st;
|
||||
int rate = av_q2d(find_fps(s, st));
|
||||
|
||||
if (!tag)
|
||||
tag = MKTAG('m', '2', 'v', '1'); //fallback tag
|
||||
|
||||
if (track->enc->pix_fmt == AV_PIX_FMT_YUV420P) {
|
||||
if (track->enc->width == 1280 && track->enc->height == 720) {
|
||||
if (!interlaced) {
|
||||
|
||||
@@ -414,14 +414,14 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if (mp3->pics_to_write) {
|
||||
/* buffer audio packets until we get all the pictures */
|
||||
AVPacketList *pktl = av_mallocz(sizeof(*pktl));
|
||||
int ret;
|
||||
if (!pktl)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
pktl->pkt = *pkt;
|
||||
pktl->pkt.buf = av_buffer_ref(pkt->buf);
|
||||
if (!pktl->pkt.buf) {
|
||||
ret = av_copy_packet(&pktl->pkt, pkt);
|
||||
if (ret < 0) {
|
||||
av_freep(&pktl);
|
||||
return AVERROR(ENOMEM);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (mp3->queue_end)
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
c->curbits = (curbits + size2) & 0x1F;
|
||||
|
||||
if ((ret = av_new_packet(pkt, size)) < 0)
|
||||
if ((ret = av_new_packet(pkt, size + 4)) < 0)
|
||||
return ret;
|
||||
|
||||
pkt->data[0] = curbits;
|
||||
|
||||
@@ -1222,6 +1222,11 @@ static int parse_MP4SLDescrTag(MP4DescrParseContext *d, int64_t off, int len)
|
||||
descr->sl.timestamp_res = avio_rb32(&d->pb);
|
||||
avio_rb32(&d->pb);
|
||||
descr->sl.timestamp_len = avio_r8(&d->pb);
|
||||
if (descr->sl.timestamp_len > 64) {
|
||||
avpriv_request_sample(NULL, "timestamp_len > 64");
|
||||
descr->sl.timestamp_len = 64;
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
descr->sl.ocr_len = avio_r8(&d->pb);
|
||||
descr->sl.au_len = avio_r8(&d->pb);
|
||||
descr->sl.inst_bitrate_len = avio_r8(&d->pb);
|
||||
@@ -1333,7 +1338,7 @@ static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, int section_le
|
||||
AVStream *st;
|
||||
if (ts->pids[pid]->es_id != mp4_descr[i].es_id)
|
||||
continue;
|
||||
if (!(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES)) {
|
||||
if (ts->pids[pid]->type != MPEGTS_PES) {
|
||||
av_log(s, AV_LOG_ERROR, "pid %x is not PES\n", pid);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ static void mpegts_write_pat(AVFormatContext *s)
|
||||
data, q - data);
|
||||
}
|
||||
|
||||
static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
|
||||
static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
|
||||
{
|
||||
MpegTSWrite *ts = s->priv_data;
|
||||
uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr;
|
||||
@@ -315,6 +315,10 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
|
||||
stream_type = STREAM_TYPE_PRIVATE_DATA;
|
||||
break;
|
||||
}
|
||||
|
||||
if (q - data > sizeof(data) - 32)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
*q++ = stream_type;
|
||||
put16(&q, 0xe000 | ts_st->pid);
|
||||
desc_length_ptr = q;
|
||||
@@ -346,7 +350,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
|
||||
len_ptr = q++;
|
||||
*len_ptr = 0;
|
||||
|
||||
for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
|
||||
for (p = lang->value; next && *len_ptr < 255 / 4 * 4 && q - data < sizeof(data) - 4; p = next + 1) {
|
||||
next = strchr(p, ',');
|
||||
if (strlen(p) != 3 && (!next || next != p + 3))
|
||||
continue; /* not a 3-letter code */
|
||||
@@ -418,6 +422,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
|
||||
}
|
||||
mpegts_write_section1(&service->pmt, PMT_TID, service->sid, ts->tables_version, 0, 0,
|
||||
data, q - data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* NOTE: str == NULL is accepted for an empty string */
|
||||
|
||||
@@ -421,6 +421,12 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
|
||||
av_dlog(s, "compute_pkt_fields2: pts:%s dts:%s cur_dts:%s b:%d size:%d st:%d\n",
|
||||
av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), delay, pkt->size, pkt->stream_index);
|
||||
|
||||
if (pkt->duration < 0 && st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
|
||||
av_log(s, AV_LOG_WARNING, "Packet with invalid duration %d in stream %d\n",
|
||||
pkt->duration, pkt->stream_index);
|
||||
pkt->duration = 0;
|
||||
}
|
||||
|
||||
/* duration field */
|
||||
if (pkt->duration == 0) {
|
||||
ff_compute_frame_duration(&num, &den, st, NULL, pkt);
|
||||
|
||||
@@ -351,7 +351,7 @@ static int vorbis_packet(AVFormatContext *s, int idx)
|
||||
* here we parse the duration of each packet in the first page and compare
|
||||
* the total duration to the page granule to find the encoder delay and
|
||||
* set the first timestamp */
|
||||
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) {
|
||||
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS) && (int64_t)os->granule>=0) {
|
||||
int seg, d;
|
||||
uint8_t *last_pkt = os->buf + os->pstart;
|
||||
uint8_t *next_pkt = last_pkt;
|
||||
|
||||
@@ -293,7 +293,7 @@ static int oma_read_header(AVFormatContext *s)
|
||||
ID3v2ExtraMeta *extra_meta = NULL;
|
||||
OMAContext *oc = s->priv_data;
|
||||
|
||||
ff_id3v2_read(s, ID3v2_EA3_MAGIC, &extra_meta);
|
||||
ff_id3v2_read(s, ID3v2_EA3_MAGIC, &extra_meta, 0);
|
||||
ret = avio_read(s->pb, buf, EA3_HEADER_SIZE);
|
||||
if (ret < EA3_HEADER_SIZE)
|
||||
return -1;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user