From 3e901cbc753ec6ddd20ebec4efd1e6f2bd404b39 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 30 Mar 2012 22:07:56 +0200 Subject: [PATCH 01/10] avconv: reindent. --- avconv.c | 100 +++++++++++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/avconv.c b/avconv.c index ee0c0c2dbf..461d23445e 100644 --- a/avconv.c +++ b/avconv.c @@ -3282,41 +3282,41 @@ static int opt_map(OptionsContext *o, const char *opt, const char *arg) exit_program(1); } } else { - file_idx = strtol(map, &p, 0); - if (file_idx >= nb_input_files || file_idx < 0) { - av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx); - exit_program(1); - } - if (negative) - /* disable some already defined maps */ - for (i = 0; i < o->nb_stream_maps; i++) { - m = &o->stream_maps[i]; - if (file_idx == m->file_index && - check_stream_specifier(input_files[m->file_index]->ctx, - input_files[m->file_index]->ctx->streams[m->stream_index], - *p == ':' ? p + 1 : p) > 0) - m->disabled = 1; + file_idx = strtol(map, &p, 0); + if (file_idx >= nb_input_files || file_idx < 0) { + av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx); + exit_program(1); } - else - for (i = 0; i < input_files[file_idx]->nb_streams; i++) { - if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i], - *p == ':' ? p + 1 : p) <= 0) - continue; - o->stream_maps = grow_array(o->stream_maps, sizeof(*o->stream_maps), - &o->nb_stream_maps, o->nb_stream_maps + 1); - m = &o->stream_maps[o->nb_stream_maps - 1]; - - m->file_index = file_idx; - m->stream_index = i; - - if (sync_file_idx >= 0) { - m->sync_file_index = sync_file_idx; - m->sync_stream_index = sync_stream_idx; - } else { - m->sync_file_index = file_idx; - m->sync_stream_index = i; + if (negative) + /* disable some already defined maps */ + for (i = 0; i < o->nb_stream_maps; i++) { + m = &o->stream_maps[i]; + if (file_idx == m->file_index && + check_stream_specifier(input_files[m->file_index]->ctx, + input_files[m->file_index]->ctx->streams[m->stream_index], + *p == ':' ? p + 1 : p) > 0) + m->disabled = 1; + } + else + for (i = 0; i < input_files[file_idx]->nb_streams; i++) { + if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i], + *p == ':' ? p + 1 : p) <= 0) + continue; + o->stream_maps = grow_array(o->stream_maps, sizeof(*o->stream_maps), + &o->nb_stream_maps, o->nb_stream_maps + 1); + m = &o->stream_maps[o->nb_stream_maps - 1]; + + m->file_index = file_idx; + m->stream_index = i; + + if (sync_file_idx >= 0) { + m->sync_file_index = sync_file_idx; + m->sync_stream_index = sync_stream_idx; + } else { + m->sync_file_index = file_idx; + m->sync_stream_index = i; + } } - } } if (!m) { @@ -4316,24 +4316,24 @@ loop_end: } init_output_filter(ofilter, o, oc); } else { - ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index]; - switch (ist->st->codec->codec_type) { - case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc); break; - case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc); break; - case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(o, oc); break; - case AVMEDIA_TYPE_DATA: ost = new_data_stream(o, oc); break; - case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc); break; - default: - av_log(NULL, AV_LOG_FATAL, "Cannot map stream #%d:%d - unsupported type.\n", - map->file_index, map->stream_index); - exit_program(1); - } + ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index]; + switch (ist->st->codec->codec_type) { + case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc); break; + case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc); break; + case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(o, oc); break; + case AVMEDIA_TYPE_DATA: ost = new_data_stream(o, oc); break; + case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc); break; + default: + av_log(NULL, AV_LOG_FATAL, "Cannot map stream #%d:%d - unsupported type.\n", + map->file_index, map->stream_index); + exit_program(1); + } - ost->source_index = input_files[map->file_index]->ist_index + map->stream_index; - ost->sync_ist = input_streams[input_files[map->sync_file_index]->ist_index + - map->sync_stream_index]; - ist->discard = 0; - ist->st->discard = AVDISCARD_NONE; + ost->source_index = input_files[map->file_index]->ist_index + map->stream_index; + ost->sync_ist = input_streams[input_files[map->sync_file_index]->ist_index + + map->sync_stream_index]; + ist->discard = 0; + ist->st->discard = AVDISCARD_NONE; } } } From 89605e4aa018f75fef1de531449383b0e9d1bfe1 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 1 Apr 2012 19:01:37 +0200 Subject: [PATCH 02/10] avconv: send EOF to vsrc_buffer. --- avconv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/avconv.c b/avconv.c index 461d23445e..a8824efff4 100644 --- a/avconv.c +++ b/avconv.c @@ -2216,6 +2216,9 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int quality = same_quant ? decoded_frame->quality : 0; if (!*got_output) { /* no picture yet */ + if (!pkt->size) + for (i = 0; i < ist->nb_filters; i++) + av_buffersrc_buffer(ist->filters[i]->filter, NULL); return ret; } decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts, From 9e8aae443b4b3f377ccb038a6444f4c33dc5dc78 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 2 Apr 2012 20:13:29 +0200 Subject: [PATCH 03/10] avconv: flush decoders immediately after an EOF. Prevents extensive buffering when overlaying a single picture. --- avconv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/avconv.c b/avconv.c index a8824efff4..347f80493d 100644 --- a/avconv.c +++ b/avconv.c @@ -3054,6 +3054,13 @@ static int transcode(void) } if (ret < 0) { input_files[file_index]->eof_reached = 1; + + for (i = 0; i < input_files[file_index]->nb_streams; i++) { + ist = input_streams[input_files[file_index]->ist_index + i]; + if (ist->decoding_needed) + output_packet(ist, NULL); + } + if (opt_shortest) break; else @@ -3125,7 +3132,7 @@ static int transcode(void) /* at the end of stream, we must flush the decoder buffers */ for (i = 0; i < nb_input_streams; i++) { ist = input_streams[i]; - if (ist->decoding_needed) { + if (!input_files[ist->file_index]->eof_reached && ist->decoding_needed) { output_packet(ist, NULL); } } From 7ce118bae5cd6b29692e0b3963d48a5610823322 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 3 Apr 2012 08:32:23 +0200 Subject: [PATCH 04/10] doc/filters: update documentation. --- doc/filters.texi | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index f0367bfdc2..b012dc791f 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -17,10 +17,11 @@ output pads is called a "sink". @anchor{Filtergraph syntax} @section Filtergraph syntax -A filtergraph can be represented using a textual representation, which -is recognized by the @code{-vf} and @code{-af} options in @command{avconv} -and @command{avplay}, and by the @code{av_parse_graph()} function defined in -@file{libavfilter/avfiltergraph}. +A filtergraph can be represented using a textual representation, which is +recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex} +options in @command{avconv} and @option{-vf} in @command{avplay}, and by the +@code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} function defined in +@file{libavfilter/avfiltergraph.h}. A filterchain consists of a sequence of connected filters, each one connected to the previous one in the sequence. A filterchain is @@ -1125,15 +1126,12 @@ Follow some examples: overlay=main_w-overlay_w-10:main_h-overlay_h-10 # insert a transparent PNG logo in the bottom left corner of the input -movie=logo.png [logo]; -[in][logo] overlay=10:main_h-overlay_h-10 [out] +avconv -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output # insert 2 different transparent PNG logos (second logo on bottom # right corner): -movie=logo1.png [logo1]; -movie=logo2.png [logo2]; -[in][logo1] overlay=10:H-h-10 [in+logo1]; -[in+logo1][logo2] overlay=W-w-10:H-h-10 [out] +avconv -i input -i logo1 -i logo2 -filter_complex +'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output # add a transparent color layer on top of the main video, # WxH specifies the size of the main input to the overlay filter From aff01de6415f1ba022f1a58e354ad6e4d0796e97 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 15 Apr 2012 21:08:37 +0200 Subject: [PATCH 05/10] graphparser: set next to NULL on an entry extracted from inputs list Prevents it from referring to the rest of the list. --- libavfilter/graphparser.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index f318984397..b3f295f933 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -229,9 +229,10 @@ static int link_filter_inouts(AVFilterContext *filt_ctx, for (pad = 0; pad < filt_ctx->input_count; pad++) { AVFilterInOut *p = *curr_inputs; - if (p) + if (p) { *curr_inputs = (*curr_inputs)->next; - else if (!(p = av_mallocz(sizeof(*p)))) + p->next = NULL; + } else if (!(p = av_mallocz(sizeof(*p)))) return AVERROR(ENOMEM); if (p->filter_ctx) { From 05afc5f57d19ab403f4c798b5a479ae016a2307c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 4 Apr 2012 17:13:13 +0200 Subject: [PATCH 06/10] dv: Move static tables only used in one place to where they are used. --- libavcodec/dv.c | 31 +++++++++++++++++++++++++++++++ libavcodec/dvdec.c | 2 ++ libavcodec/dvquant.h | 32 -------------------------------- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 1a0075b57b..86ff211ab7 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -167,6 +167,15 @@ static inline void dv_calc_mb_coordinates(const DVprofile *d, int chan, int seq, } } +/* quantization quanta by QNO for DV100 */ +static const uint8_t dv100_qstep[16] = { + 1, /* QNO = 0 and 1 both have no quantization */ + 1, + 2, 3, 4, 5, 6, 7, 8, 16, 18, 20, 22, 24, 28, 52 +}; + +static const uint8_t dv_quant_areas[4] = { 6, 21, 43, 64 }; + int ff_dv_init_dynamic_tables(const DVprofile *d) { int j,i,c,s,p; @@ -467,6 +476,28 @@ static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, uint8_t *data, return 0; } +static const int dv_weight_bits = 18; +static const int dv_weight_88[64] = { + 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536, + 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935, + 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916, + 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433, + 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704, + 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568, + 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627, + 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258, +}; +static const int dv_weight_248[64] = { + 131072, 242189, 257107, 237536, 229376, 200636, 242189, 223754, + 224969, 196781, 262144, 242189, 229376, 200636, 257107, 237536, + 211916, 185364, 235923, 217965, 229376, 211916, 206433, 180568, + 242189, 223754, 224969, 196781, 211916, 185364, 235923, 217965, + 200704, 175557, 222935, 205965, 200636, 185364, 195068, 170627, + 229376, 211916, 206433, 180568, 200704, 175557, 222935, 205965, + 175557, 153560, 188995, 174609, 165371, 144651, 200636, 185364, + 195068, 170627, 175557, 153560, 188995, 174609, 165371, 144651, +}; + static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, int linesize, DVVideoContext *s, int bias) { const int *weight; diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 8f52959e0c..582574b14d 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -54,6 +54,8 @@ typedef struct BlockInfo { int shift_offset; } BlockInfo; +static const int dv_iweight_bits = 14; + /* decode AC coefficients */ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) { diff --git a/libavcodec/dvquant.h b/libavcodec/dvquant.h index 7bd0cdc01a..feb778ab15 100644 --- a/libavcodec/dvquant.h +++ b/libavcodec/dvquant.h @@ -56,39 +56,7 @@ static const uint8_t dv_quant_shifts[22][4] = { }; static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 }; -static const uint8_t dv_quant_areas[4] = { 6, 21, 43, 64 }; -/* quantization quanta by QNO for DV100 */ -static const uint8_t dv100_qstep[16] = { - 1, /* QNO = 0 and 1 both have no quantization */ - 1, - 2, 3, 4, 5, 6, 7, 8, 16, 18, 20, 22, 24, 28, 52 -}; - -/* DV25/50 DCT coefficient weights and inverse weights */ -/* created by dvtables.py */ -static const int dv_weight_bits = 18; -static const int dv_weight_88[64] = { - 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536, - 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935, - 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916, - 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433, - 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704, - 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568, - 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627, - 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258, -}; -static const int dv_weight_248[64] = { - 131072, 242189, 257107, 237536, 229376, 200636, 242189, 223754, - 224969, 196781, 262144, 242189, 229376, 200636, 257107, 237536, - 211916, 185364, 235923, 217965, 229376, 211916, 206433, 180568, - 242189, 223754, 224969, 196781, 211916, 185364, 235923, 217965, - 200704, 175557, 222935, 205965, 200636, 185364, 195068, 170627, - 229376, 211916, 206433, 180568, 200704, 175557, 222935, 205965, - 175557, 153560, 188995, 174609, 165371, 144651, 200636, 185364, - 195068, 170627, 175557, 153560, 188995, 174609, 165371, 144651, -}; -static const int dv_iweight_bits = 14; static const int dv_iweight_88[64] = { 32768, 16710, 16710, 17735, 17015, 17735, 18197, 18079, 18079, 18197, 18725, 18559, 19196, 18559, 18725, 19284, From a3dbd459ffe1eef2705090d33e3bdaac539bb62f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 4 Apr 2012 17:32:55 +0200 Subject: [PATCH 07/10] dv: Merge dvquant.h into dvdata.c where all other DV tables reside. --- libavcodec/dv.c | 17 +++--- libavcodec/dvdata.c | 93 ++++++++++++++++++++++++++++++++ libavcodec/dvdata.h | 10 ++++ libavcodec/dvdec.c | 3 +- libavcodec/dvquant.h | 125 ------------------------------------------- 5 files changed, 112 insertions(+), 136 deletions(-) delete mode 100644 libavcodec/dvquant.h diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 86ff211ab7..034daac2d7 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -46,7 +46,6 @@ #include "put_bits.h" #include "simple_idct.h" #include "dvdata.h" -#include "dvquant.h" #include "dv_tablegen.h" /* XXX: also include quantization */ @@ -204,11 +203,11 @@ int ff_dv_init_dynamic_tables(const DVprofile *d) factor1 = &d->idct_factor[0]; factor2 = &d->idct_factor[DV_PROFILE_IS_HD(d)?4096:2816]; if (d->height == 720) { - iweight1 = &dv_iweight_720_y[0]; - iweight2 = &dv_iweight_720_c[0]; + iweight1 = &ff_dv_iweight_720_y[0]; + iweight2 = &ff_dv_iweight_720_c[0]; } else { - iweight1 = &dv_iweight_1080_y[0]; - iweight2 = &dv_iweight_1080_c[0]; + iweight1 = &ff_dv_iweight_1080_y[0]; + iweight2 = &ff_dv_iweight_1080_c[0]; } if (DV_PROFILE_IS_HD(d)) { for (c = 0; c < 4; c++) { @@ -220,12 +219,12 @@ int ff_dv_init_dynamic_tables(const DVprofile *d) } } } else { - iweight1 = &dv_iweight_88[0]; - for (j = 0; j < 2; j++, iweight1 = &dv_iweight_248[0]) { + iweight1 = &ff_dv_iweight_88[0]; + for (j = 0; j < 2; j++, iweight1 = &ff_dv_iweight_248[0]) { for (s = 0; s < 22; s++) { for (i = c = 0; c < 4; c++) { for (; i < dv_quant_areas[c]; i++) { - *factor1 = iweight1[i] << (dv_quant_shifts[s][c] + 1); + *factor1 = iweight1[i] << (ff_dv_quant_shifts[s][c] + 1); *factor2++ = (*factor1++) << 1; } } @@ -609,7 +608,7 @@ static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos) size[i] = 0; for (j = 0; j < 6; j++, b++) { for (a = 0; a < 4; a++) { - if (b->area_q[a] != dv_quant_shifts[qnos[i] + dv_quant_offset[b->cno]][a]) { + if (b->area_q[a] != ff_dv_quant_shifts[qnos[i] + ff_dv_quant_offset[b->cno]][a]) { b->bit_size[a] = 1; // 4 areas 4 bits for EOB :) b->area_q[a]++; prev = b->prev[a]; diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c index 6d123a9741..353ecd5aab 100644 --- a/libavcodec/dvdata.c +++ b/libavcodec/dvdata.c @@ -29,6 +29,99 @@ #include "avcodec.h" #include "dvdata.h" +/* unquant tables (not used directly) */ +const uint8_t ff_dv_quant_shifts[22][4] = { + { 3,3,4,4 }, + { 3,3,4,4 }, + { 2,3,3,4 }, + { 2,3,3,4 }, + { 2,2,3,3 }, + { 2,2,3,3 }, + { 1,2,2,3 }, + { 1,2,2,3 }, + { 1,1,2,2 }, + { 1,1,2,2 }, + { 0,1,1,2 }, + { 0,1,1,2 }, + { 0,0,1,1 }, + { 0,0,1,1 }, + { 0,0,0,1 }, + { 0,0,0,0 }, + { 0,0,0,0 }, + { 0,0,0,0 }, + { 0,0,0,0 }, + { 0,0,0,0 }, + { 0,0,0,0 }, + { 0,0,0,0 }, +}; + +const uint8_t ff_dv_quant_offset[4] = { 6, 3, 0, 1 }; + +const int ff_dv_iweight_88[64] = { + 32768, 16710, 16710, 17735, 17015, 17735, 18197, 18079, + 18079, 18197, 18725, 18559, 19196, 18559, 18725, 19284, + 19108, 19692, 19692, 19108, 19284, 21400, 19645, 20262, + 20214, 20262, 19645, 21400, 22733, 21845, 20867, 20815, + 20815, 20867, 21845, 22733, 23173, 23173, 21400, 21400, + 21400, 23173, 23173, 24600, 23764, 22017, 22017, 23764, + 24600, 25267, 24457, 22672, 24457, 25267, 25971, 25191, + 25191, 25971, 26715, 27962, 26715, 29642, 29642, 31536, +}; +const int ff_dv_iweight_248[64] = { + 32768, 17735, 16710, 18079, 18725, 21400, 17735, 19196, + 19108, 21845, 16384, 17735, 18725, 21400, 16710, 18079, + 20262, 23173, 18197, 19692, 18725, 20262, 20815, 23764, + 17735, 19196, 19108, 21845, 20262, 23173, 18197, 19692, + 21400, 24457, 19284, 20867, 21400, 23173, 22017, 25191, + 18725, 20262, 20815, 23764, 21400, 24457, 19284, 20867, + 24457, 27962, 22733, 24600, 25971, 29642, 21400, 23173, + 22017, 25191, 24457, 27962, 22733, 24600, 25971, 29642, +}; + +/** + * The "inverse" DV100 weights are actually just the spec weights (zig-zagged). + */ +const int ff_dv_iweight_1080_y[64] = { + 128, 16, 16, 17, 17, 17, 18, 18, + 18, 18, 18, 18, 19, 18, 18, 19, + 19, 19, 19, 19, 19, 42, 38, 40, + 40, 40, 38, 42, 44, 43, 41, 41, + 41, 41, 43, 44, 45, 45, 42, 42, + 42, 45, 45, 48, 46, 43, 43, 46, + 48, 49, 48, 44, 48, 49, 101, 98, + 98, 101, 104, 109, 104, 116, 116, 123, +}; +const int ff_dv_iweight_1080_c[64] = { + 128, 16, 16, 17, 17, 17, 25, 25, + 25, 25, 26, 25, 26, 25, 26, 26, + 26, 27, 27, 26, 26, 42, 38, 40, + 40, 40, 38, 42, 44, 43, 41, 41, + 41, 41, 43, 44, 91, 91, 84, 84, + 84, 91, 91, 96, 93, 86, 86, 93, + 96, 197, 191, 177, 191, 197, 203, 197, + 197, 203, 209, 219, 209, 232, 232, 246, +}; +const int ff_dv_iweight_720_y[64] = { + 128, 16, 16, 17, 17, 17, 18, 18, + 18, 18, 18, 18, 19, 18, 18, 19, + 19, 19, 19, 19, 19, 42, 38, 40, + 40, 40, 38, 42, 44, 43, 41, 41, + 41, 41, 43, 44, 68, 68, 63, 63, + 63, 68, 68, 96, 92, 86, 86, 92, + 96, 98, 96, 88, 96, 98, 202, 196, + 196, 202, 208, 218, 208, 232, 232, 246, +}; +const int ff_dv_iweight_720_c[64] = { + 128, 24, 24, 26, 26, 26, 36, 36, + 36, 36, 36, 36, 38, 36, 36, 38, + 38, 38, 38, 38, 38, 84, 76, 80, + 80, 80, 76, 84, 88, 86, 82, 82, + 82, 82, 86, 88, 182, 182, 168, 168, + 168, 182, 182, 192, 186, 192, 172, 186, + 192, 394, 382, 354, 382, 394, 406, 394, + 394, 406, 418, 438, 418, 464, 464, 492, +}; + static DVwork_chunk work_chunks_dv25pal [1*12*27]; static DVwork_chunk work_chunks_dv25pal411[1*12*27]; static DVwork_chunk work_chunks_dv25ntsc [1*10*27]; diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h index 8b4811ac69..54a4bf1f67 100644 --- a/libavcodec/dvdata.h +++ b/libavcodec/dvdata.h @@ -104,6 +104,16 @@ enum dv_pack_type { dv_unknown_pack = 0xff, }; +extern const uint8_t ff_dv_quant_shifts[22][4]; +extern const uint8_t ff_dv_quant_offset[4]; + +extern const int ff_dv_iweight_88[64]; +extern const int ff_dv_iweight_248[64]; +extern const int ff_dv_iweight_1080_y[64]; +extern const int ff_dv_iweight_1080_c[64]; +extern const int ff_dv_iweight_720_y[64]; +extern const int ff_dv_iweight_720_c[64]; + #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10) #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 1)) #define DV_PROFILE_IS_720p50(p) (((p)->video_stype == 0x18) && ((p)->dsf == 1)) diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 582574b14d..6b77a40568 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -42,7 +42,6 @@ #include "put_bits.h" #include "simple_idct.h" #include "dvdata.h" -#include "dvquant.h" typedef struct BlockInfo { const uint32_t *factor_table; @@ -183,7 +182,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) mb->idct_put = s->idct_put[dct_mode && log2_blocksize == 3]; mb->scan_table = s->dv_zigzag[dct_mode]; mb->factor_table = &s->sys->idct_factor[(class1 == 3)*2*22*64 + dct_mode*22*64 + - (quant + dv_quant_offset[class1])*64]; + (quant + ff_dv_quant_offset[class1])*64]; } dc = dc << 2; /* convert to unsigned because 128 is not added in the diff --git a/libavcodec/dvquant.h b/libavcodec/dvquant.h deleted file mode 100644 index feb778ab15..0000000000 --- a/libavcodec/dvquant.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Quant and Weight for DV codec - * Copyright (c) 2002 Fabrice Bellard - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * Constants for DV codec. - */ - -#ifndef AVCODEC_DVQUANT_H -#define AVCODEC_DVQUANT_H - -#include - -/* unquant tables (not used directly) */ -static const uint8_t dv_quant_shifts[22][4] = { - { 3,3,4,4 }, - { 3,3,4,4 }, - { 2,3,3,4 }, - { 2,3,3,4 }, - { 2,2,3,3 }, - { 2,2,3,3 }, - { 1,2,2,3 }, - { 1,2,2,3 }, - { 1,1,2,2 }, - { 1,1,2,2 }, - { 0,1,1,2 }, - { 0,1,1,2 }, - { 0,0,1,1 }, - { 0,0,1,1 }, - { 0,0,0,1 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, -}; - -static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 }; - -static const int dv_iweight_88[64] = { - 32768, 16710, 16710, 17735, 17015, 17735, 18197, 18079, - 18079, 18197, 18725, 18559, 19196, 18559, 18725, 19284, - 19108, 19692, 19692, 19108, 19284, 21400, 19645, 20262, - 20214, 20262, 19645, 21400, 22733, 21845, 20867, 20815, - 20815, 20867, 21845, 22733, 23173, 23173, 21400, 21400, - 21400, 23173, 23173, 24600, 23764, 22017, 22017, 23764, - 24600, 25267, 24457, 22672, 24457, 25267, 25971, 25191, - 25191, 25971, 26715, 27962, 26715, 29642, 29642, 31536, -}; -static const int dv_iweight_248[64] = { - 32768, 17735, 16710, 18079, 18725, 21400, 17735, 19196, - 19108, 21845, 16384, 17735, 18725, 21400, 16710, 18079, - 20262, 23173, 18197, 19692, 18725, 20262, 20815, 23764, - 17735, 19196, 19108, 21845, 20262, 23173, 18197, 19692, - 21400, 24457, 19284, 20867, 21400, 23173, 22017, 25191, - 18725, 20262, 20815, 23764, 21400, 24457, 19284, 20867, - 24457, 27962, 22733, 24600, 25971, 29642, 21400, 23173, - 22017, 25191, 24457, 27962, 22733, 24600, 25971, 29642, -}; - -/** - * The "inverse" DV100 weights are actually just the spec weights (zig-zagged). - */ -static const int dv_iweight_1080_y[64] = { - 128, 16, 16, 17, 17, 17, 18, 18, - 18, 18, 18, 18, 19, 18, 18, 19, - 19, 19, 19, 19, 19, 42, 38, 40, - 40, 40, 38, 42, 44, 43, 41, 41, - 41, 41, 43, 44, 45, 45, 42, 42, - 42, 45, 45, 48, 46, 43, 43, 46, - 48, 49, 48, 44, 48, 49, 101, 98, - 98, 101, 104, 109, 104, 116, 116, 123, -}; -static const int dv_iweight_1080_c[64] = { - 128, 16, 16, 17, 17, 17, 25, 25, - 25, 25, 26, 25, 26, 25, 26, 26, - 26, 27, 27, 26, 26, 42, 38, 40, - 40, 40, 38, 42, 44, 43, 41, 41, - 41, 41, 43, 44, 91, 91, 84, 84, - 84, 91, 91, 96, 93, 86, 86, 93, - 96, 197, 191, 177, 191, 197, 203, 197, - 197, 203, 209, 219, 209, 232, 232, 246, -}; -static const int dv_iweight_720_y[64] = { - 128, 16, 16, 17, 17, 17, 18, 18, - 18, 18, 18, 18, 19, 18, 18, 19, - 19, 19, 19, 19, 19, 42, 38, 40, - 40, 40, 38, 42, 44, 43, 41, 41, - 41, 41, 43, 44, 68, 68, 63, 63, - 63, 68, 68, 96, 92, 86, 86, 92, - 96, 98, 96, 88, 96, 98, 202, 196, - 196, 202, 208, 218, 208, 232, 232, 246, -}; -static const int dv_iweight_720_c[64] = { - 128, 24, 24, 26, 26, 26, 36, 36, - 36, 36, 36, 36, 38, 36, 36, 38, - 38, 38, 38, 38, 38, 84, 76, 80, - 80, 80, 76, 84, 88, 86, 82, 82, - 82, 82, 86, 88, 182, 182, 168, 168, - 168, 182, 182, 192, 186, 192, 172, 186, - 192, 394, 382, 354, 382, 394, 406, 394, - 394, 406, 418, 438, 418, 464, 464, 492, -}; - -#endif /* AVCODEC_DVQUANT_H */ From b553a425fbd20b38a6cac5fd5e22ecca71e1f599 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 28 Feb 2012 20:44:41 +0100 Subject: [PATCH 08/10] doc: Update sample Vim config with suitable (function) indentation settings. --- doc/developer.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/developer.texi b/doc/developer.texi index a4fdf3a625..de642396dc 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -215,6 +215,8 @@ the following snippet into your @file{.vimrc}: set expandtab set shiftwidth=4 set softtabstop=4 +set cindent +set cinoptions=(0 " allow tabs in Makefiles autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=8 " Trailing whitespace and tabs are forbidden, so highlight them. From 87a246341b0a87122391f9dbf00cae7bc3a62d90 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 15 Apr 2012 08:11:55 -0700 Subject: [PATCH 09/10] h264: use proper PROLOGUE statement for a function using 8 registers. Fixes crashes when using biweight on win64. --- libavcodec/x86/h264_weight_10bit.asm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/x86/h264_weight_10bit.asm b/libavcodec/x86/h264_weight_10bit.asm index c4b12984f6..dec9aba461 100644 --- a/libavcodec/x86/h264_weight_10bit.asm +++ b/libavcodec/x86/h264_weight_10bit.asm @@ -160,7 +160,7 @@ DECLARE_REG_TMP 7 %macro BIWEIGHT_PROLOGUE 0 .prologue - PROLOGUE 0,7,8 + PROLOGUE 0,8,8 movifnidn r0, r0mp movifnidn r1, r1mp movifnidn r2d, r2m @@ -218,7 +218,7 @@ DECLARE_REG_TMP 7 %endmacro %macro BIWEIGHT_FUNC_DBL 1 -cglobal h264_biweight_16_10_%1, 0, 8, 8 +cglobal h264_biweight_16_10_%1 BIWEIGHT_PROLOGUE BIWEIGHT_SETUP %1 .nextrow @@ -238,7 +238,7 @@ BIWEIGHT_FUNC_DBL sse2 BIWEIGHT_FUNC_DBL sse4 %macro BIWEIGHT_FUNC 1 -cglobal h264_biweight_8_10_%1, 0, 8, 8 +cglobal h264_biweight_8_10_%1 BIWEIGHT_PROLOGUE BIWEIGHT_SETUP %1 .nextrow @@ -256,7 +256,7 @@ BIWEIGHT_FUNC sse2 BIWEIGHT_FUNC sse4 %macro BIWEIGHT_FUNC_HALF 1 -cglobal h264_biweight_4_10_%1, 0, 8, 8 +cglobal h264_biweight_4_10_%1 BIWEIGHT_PROLOGUE BIWEIGHT_SETUP %1 sar r3d, 1 From 8b84e082ed27fb635fca524fbd14b1db094ee8b0 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 16 Apr 2012 15:48:05 +0100 Subject: [PATCH 10/10] indeo3: add parens around some macro arguments Without these, the expansion contains things like --1 with some compilers resulting in build errors. Signed-off-by: Mans Rullgard --- libavcodec/indeo3data.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/indeo3data.h b/libavcodec/indeo3data.h index 6bb55ce902..55164c2531 100644 --- a/libavcodec/indeo3data.h +++ b/libavcodec/indeo3data.h @@ -247,8 +247,8 @@ * Expand a pair of delta values (a,b) * into two/four delta entries. */ -#define E2(a, b) PD(a, b), PD(-a, -b) -#define E4(a, b) PD(a, b), PD(-a, -b), PD(b, a), PD(-b, -a) +#define E2(a, b) PD(a, b), PD(-(a), -(b)) +#define E4(a, b) PD(a, b), PD(-(a), -(b)), PD(b, a), PD(-(b), -(a)) /* * VQ tables for 4x4 block modes.