From 7204ec1a88ab286023cf9e1e096dac983c198a37 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Nov 2011 13:48:45 +0100 Subject: [PATCH 01/22] avconv: split off streamcopy handling into a separate loop. This is easier to understand and is less likely to break horribly when a stream is to be both decoded and copied. --- avconv.c | 162 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 90 insertions(+), 72 deletions(-) diff --git a/avconv.c b/avconv.c index c962b2bb33..0537e8cdc2 100644 --- a/avconv.c +++ b/avconv.c @@ -1528,6 +1528,83 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams) } } +/* + * Check whether a packet from ist should be written into ost at this time + */ +static int check_output_constraints(InputStream *ist, OutputStream *ost) +{ + OutputFile *of = &output_files[ost->file_index]; + int ist_index = ist - input_streams; + + if (ost->source_index != ist_index) + return 0; + + if (of->start_time && ist->pts < of->start_time) + return 0; + + if (of->recording_time != INT64_MAX && + av_compare_ts(ist->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time, + (AVRational){1, 1000000}) >= 0) { + ost->is_past_recording_time = 1; + return 0; + } + + return 1; +} + +static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt) +{ + OutputFile *of = &output_files[ost->file_index]; + int64_t ost_tb_start_time = av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base); + AVPacket opkt; + + av_init_packet(&opkt); + + if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && + !ost->copy_initial_nonkeyframes) + return; + + /* force the input stream PTS */ + if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) + audio_size += pkt->size; + else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + video_size += pkt->size; + ost->sync_opts++; + } + + opkt.stream_index = ost->index; + if (pkt->pts != AV_NOPTS_VALUE) + opkt.pts = av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time; + else + opkt.pts = AV_NOPTS_VALUE; + + if (pkt->dts == AV_NOPTS_VALUE) + opkt.dts = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ost->st->time_base); + else + opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base); + opkt.dts -= ost_tb_start_time; + + opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base); + opkt.flags = pkt->flags; + + //FIXME remove the following 2 lines they shall be replaced by the bitstream filters + if( ost->st->codec->codec_id != CODEC_ID_H264 + && ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO + && ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO + ) { + if (av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, pkt->data, pkt->size, pkt->flags & AV_PKT_FLAG_KEY)) + opkt.destruct = av_destruct_packet; + } else { + opkt.data = pkt->data; + opkt.size = pkt->size; + } + + write_frame(of->ctx, &opkt, ost->st->codec, ost->bitstream_filters); + ost->st->codec->frame_number++; + ost->frame_number++; + av_free_packet(&opkt); +} + /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int output_packet(InputStream *ist, int ist_index, OutputStream *ost_table, int nb_ostreams, @@ -1569,8 +1646,8 @@ static int output_packet(InputStream *ist, int ist_index, //while we have more to decode or while the decoder did output something on EOF while (avpkt.size > 0 || (!pkt && got_output)) { - uint8_t *data_buf, *decoded_data_buf; - int data_size, decoded_data_size; + uint8_t *decoded_data_buf; + int decoded_data_size; AVFrame *decoded_frame, *filtered_frame; handle_eof: ist->pts= ist->next_pts; @@ -1584,8 +1661,6 @@ static int output_packet(InputStream *ist, int ist_index, decoded_frame = filtered_frame = NULL; decoded_data_buf = NULL; /* fail safe */ decoded_data_size= 0; - data_buf = avpkt.data; - data_size = avpkt.size; subtitle_to_free = NULL; if (ist->decoding_needed) { switch(ist->st->codec->codec_type) { @@ -1604,7 +1679,6 @@ static int output_packet(InputStream *ist, int ist_index, return ret; avpkt.data += ret; avpkt.size -= ret; - data_size = ret; got_output = decoded_data_size > 0; /* Some bug in mpeg audio decoder gives */ /* decoded_data_size < 0, it seems they are overflows */ @@ -1745,23 +1819,13 @@ static int output_packet(InputStream *ist, int ist_index, /* if output time reached then transcode raw format, encode packets and output them */ for (i = 0; i < nb_ostreams; i++) { - OutputFile *of = &output_files[ost_table[i].file_index]; int frame_size; ost = &ost_table[i]; - if (ost->source_index != ist_index) - continue; - if (of->start_time && ist->pts < of->start_time) + if (!check_output_constraints(ist, ost) || !ost->encoding_needed) continue; - if (of->recording_time != INT64_MAX && - av_compare_ts(ist->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time, - (AVRational){1, 1000000}) >= 0) { - ost->is_past_recording_time = 1; - continue; - } - #if CONFIG_AVFILTER if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->input_video_filter) { @@ -1815,64 +1879,8 @@ static int output_packet(InputStream *ist, int ist_index, default: abort(); } - } else { - AVPacket opkt; - int64_t ost_tb_start_time= av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base); - - av_init_packet(&opkt); - - if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && - !ost->copy_initial_nonkeyframes) -#if !CONFIG_AVFILTER - continue; -#else - goto cont; -#endif - - /* no reencoding needed : output the packet directly */ - /* force the input stream PTS */ - - if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) - audio_size += data_size; - else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { - video_size += data_size; - ost->sync_opts++; - } - - opkt.stream_index= ost->index; - if(pkt->pts != AV_NOPTS_VALUE) - opkt.pts= av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time; - else - opkt.pts= AV_NOPTS_VALUE; - - if (pkt->dts == AV_NOPTS_VALUE) - opkt.dts = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ost->st->time_base); - else - opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base); - opkt.dts -= ost_tb_start_time; - - opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base); - opkt.flags= pkt->flags; - - //FIXME remove the following 2 lines they shall be replaced by the bitstream filters - if( ost->st->codec->codec_id != CODEC_ID_H264 - && ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO - && ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO - ) { - if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY)) - opkt.destruct= av_destruct_packet; - } else { - opkt.data = data_buf; - opkt.size = data_size; - } - - write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters); - ost->st->codec->frame_number++; - ost->frame_number++; - av_free_packet(&opkt); } #if CONFIG_AVFILTER - cont: frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]); if (ost->picref) @@ -1895,6 +1903,16 @@ fail: } discard_packet: + /* handle stream copy */ + for (i = 0; pkt && i < nb_ostreams; i++) { + ost = &ost_table[i]; + + if (!check_output_constraints(ist, ost) || ost->encoding_needed) + continue; + + do_streamcopy(ist, ost, pkt); + } + return 0; } From 51aeb6945251f91c8a9f79792706e77cf3742007 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Nov 2011 13:51:51 +0100 Subject: [PATCH 02/22] avconv: remove an always true condition and reindent. --- avconv.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/avconv.c b/avconv.c index 0537e8cdc2..d7028f4fe3 100644 --- a/avconv.c +++ b/avconv.c @@ -1856,29 +1856,27 @@ static int output_packet(InputStream *ist, int ist_index, /* set the input output pts pairs */ //ost->sync_ipts = (double)(ist->pts + input_files[ist->file_index].ts_offset - start_time)/ AV_TIME_BASE; - if (ost->encoding_needed) { - av_assert0(ist->decoding_needed); - switch(ost->st->codec->codec_type) { - case AVMEDIA_TYPE_AUDIO: - do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size); - break; - case AVMEDIA_TYPE_VIDEO: + av_assert0(ist->decoding_needed); + switch(ost->st->codec->codec_type) { + case AVMEDIA_TYPE_AUDIO: + do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size); + break; + case AVMEDIA_TYPE_VIDEO: #if CONFIG_AVFILTER - if (ost->picref->video && !ost->frame_aspect_ratio) - ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect; + if (ost->picref->video && !ost->frame_aspect_ratio) + ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect; #endif - do_video_out(os, ost, ist, filtered_frame, &frame_size, - same_quant ? quality : ost->st->codec->global_quality); - if (vstats_filename && frame_size) - do_video_stats(os, ost, frame_size); - break; - case AVMEDIA_TYPE_SUBTITLE: - do_subtitle_out(os, ost, ist, &subtitle, - pkt->pts); - break; - default: - abort(); - } + do_video_out(os, ost, ist, filtered_frame, &frame_size, + same_quant ? quality : ost->st->codec->global_quality); + if (vstats_filename && frame_size) + do_video_stats(os, ost, frame_size); + break; + case AVMEDIA_TYPE_SUBTITLE: + do_subtitle_out(os, ost, ist, &subtitle, + pkt->pts); + break; + default: + abort(); } #if CONFIG_AVFILTER frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && From 2a651b719c309c5e2fc663a5a9d6ca36153ab98f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Nov 2011 14:05:38 +0100 Subject: [PATCH 03/22] avconv: move streamcopy-only code out of decoding loop. --- avconv.c | 55 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/avconv.c b/avconv.c index d7028f4fe3..6ad26b4865 100644 --- a/avconv.c +++ b/avconv.c @@ -1605,6 +1605,16 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p av_free_packet(&opkt); } +static void rate_emu_sleep(InputStream *ist) +{ + if (input_files[ist->file_index].rate_emu) { + int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE); + int64_t now = av_gettime() - ist->start; + if (pts > now) + usleep(pts - now); + } +} + /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int output_packet(InputStream *ist, int ist_index, OutputStream *ost_table, int nb_ostreams, @@ -1645,7 +1655,7 @@ static int output_packet(InputStream *ist, int ist_index, pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); //while we have more to decode or while the decoder did output something on EOF - while (avpkt.size > 0 || (!pkt && got_output)) { + while (ist->decoding_needed && (avpkt.size > 0 || (!pkt && got_output))) { uint8_t *decoded_data_buf; int decoded_data_size; AVFrame *decoded_frame, *filtered_frame; @@ -1662,7 +1672,6 @@ static int output_packet(InputStream *ist, int ist_index, decoded_data_buf = NULL; /* fail safe */ decoded_data_size= 0; subtitle_to_free = NULL; - if (ist->decoding_needed) { switch(ist->st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO:{ if(pkt && samples_size < FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE)) { @@ -1733,23 +1742,6 @@ static int output_packet(InputStream *ist, int ist_index, default: return -1; } - } else { - switch(ist->st->codec->codec_type) { - case AVMEDIA_TYPE_AUDIO: - ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) / - ist->st->codec->sample_rate; - break; - case AVMEDIA_TYPE_VIDEO: - if (ist->st->codec->time_base.num != 0) { - int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame; - ist->next_pts += ((int64_t)AV_TIME_BASE * - ist->st->codec->time_base.num * ticks) / - ist->st->codec->time_base.den; - } - break; - } - avpkt.size = 0; - } // preprocess audio (volume) if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { @@ -1810,12 +1802,8 @@ static int output_packet(InputStream *ist, int ist_index, } /* frame rate emulation */ - if (input_files[ist->file_index].rate_emu) { - int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE); - int64_t now = av_gettime() - ist->start; - if (pts > now) - usleep(pts - now); - } + rate_emu_sleep(ist); + /* if output time reached then transcode raw format, encode packets and output them */ for (i = 0; i < nb_ostreams; i++) { @@ -1902,6 +1890,23 @@ fail: discard_packet: /* handle stream copy */ + if (!ist->decoding_needed) { + rate_emu_sleep(ist); + switch (ist->st->codec->codec_type) { + case AVMEDIA_TYPE_AUDIO: + ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) / + ist->st->codec->sample_rate; + break; + case AVMEDIA_TYPE_VIDEO: + if (ist->st->codec->time_base.num != 0) { + int ticks = ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame; + ist->next_pts += ((int64_t)AV_TIME_BASE * + ist->st->codec->time_base.num * ticks) / + ist->st->codec->time_base.den; + } + break; + } + } for (i = 0; pkt && i < nb_ostreams; i++) { ost = &ost_table[i]; From 78162b4ea28abebe1c7b87b88cd7731fd3b41073 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Nov 2011 14:06:25 +0100 Subject: [PATCH 04/22] avconv: reindent. --- avconv.c | 124 +++++++++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/avconv.c b/avconv.c index 6ad26b4865..1f8f0476fe 100644 --- a/avconv.c +++ b/avconv.c @@ -1672,76 +1672,76 @@ static int output_packet(InputStream *ist, int ist_index, decoded_data_buf = NULL; /* fail safe */ decoded_data_size= 0; subtitle_to_free = NULL; - switch(ist->st->codec->codec_type) { - case AVMEDIA_TYPE_AUDIO:{ - if(pkt && samples_size < FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE)) { - samples_size = FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE); - av_free(samples); - samples= av_malloc(samples_size); - } - decoded_data_size= samples_size; - /* XXX: could avoid copy if PCM 16 bits with same - endianness as CPU */ - ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size, - &avpkt); - if (ret < 0) - return ret; - avpkt.data += ret; - avpkt.size -= ret; - got_output = decoded_data_size > 0; - /* Some bug in mpeg audio decoder gives */ - /* decoded_data_size < 0, it seems they are overflows */ - if (!got_output) { - /* no audio frame */ - continue; - } - decoded_data_buf = (uint8_t *)samples; - ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) / - (ist->st->codec->sample_rate * ist->st->codec->channels); - break;} - case AVMEDIA_TYPE_VIDEO: - if (!(decoded_frame = avcodec_alloc_frame())) - return AVERROR(ENOMEM); - avpkt.pts = pkt_pts; - avpkt.dts = ist->pts; - pkt_pts = AV_NOPTS_VALUE; + switch(ist->st->codec->codec_type) { + case AVMEDIA_TYPE_AUDIO:{ + if(pkt && samples_size < FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE)) { + samples_size = FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE); + av_free(samples); + samples= av_malloc(samples_size); + } + decoded_data_size= samples_size; + /* XXX: could avoid copy if PCM 16 bits with same + endianness as CPU */ + ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size, + &avpkt); + if (ret < 0) + return ret; + avpkt.data += ret; + avpkt.size -= ret; + got_output = decoded_data_size > 0; + /* Some bug in mpeg audio decoder gives */ + /* decoded_data_size < 0, it seems they are overflows */ + if (!got_output) { + /* no audio frame */ + continue; + } + decoded_data_buf = (uint8_t *)samples; + ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) / + (ist->st->codec->sample_rate * ist->st->codec->channels); + break;} + case AVMEDIA_TYPE_VIDEO: + if (!(decoded_frame = avcodec_alloc_frame())) + return AVERROR(ENOMEM); + avpkt.pts = pkt_pts; + avpkt.dts = ist->pts; + pkt_pts = AV_NOPTS_VALUE; - ret = avcodec_decode_video2(ist->st->codec, - decoded_frame, &got_output, &avpkt); - quality = same_quant ? decoded_frame->quality : 0; - if (ret < 0) - goto fail; - if (!got_output) { - /* no picture yet */ - av_freep(&decoded_frame); - goto discard_packet; - } - ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts, - decoded_frame->pkt_dts); - if (ist->st->codec->time_base.num != 0) { - int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame; - ist->next_pts += ((int64_t)AV_TIME_BASE * - ist->st->codec->time_base.num * ticks) / - ist->st->codec->time_base.den; - } - avpkt.size = 0; - buffer_to_free = NULL; - pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free); - break; - case AVMEDIA_TYPE_SUBTITLE: - ret = avcodec_decode_subtitle2(ist->st->codec, - &subtitle, &got_output, &avpkt); + ret = avcodec_decode_video2(ist->st->codec, + decoded_frame, &got_output, &avpkt); + quality = same_quant ? decoded_frame->quality : 0; if (ret < 0) - return ret; + goto fail; if (!got_output) { + /* no picture yet */ + av_freep(&decoded_frame); goto discard_packet; } - subtitle_to_free = &subtitle; + ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts, + decoded_frame->pkt_dts); + if (ist->st->codec->time_base.num != 0) { + int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame; + ist->next_pts += ((int64_t)AV_TIME_BASE * + ist->st->codec->time_base.num * ticks) / + ist->st->codec->time_base.den; + } avpkt.size = 0; + buffer_to_free = NULL; + pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free); break; - default: - return -1; + case AVMEDIA_TYPE_SUBTITLE: + ret = avcodec_decode_subtitle2(ist->st->codec, + &subtitle, &got_output, &avpkt); + if (ret < 0) + return ret; + if (!got_output) { + goto discard_packet; } + subtitle_to_free = &subtitle; + avpkt.size = 0; + break; + default: + return -1; + } // preprocess audio (volume) if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { From ded28ba35b14b55302e54d35a29d6f920850770b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Nov 2011 14:39:22 +0100 Subject: [PATCH 05/22] avconv: split audio transcoding out of output_packet(). --- avconv.c | 209 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 114 insertions(+), 95 deletions(-) diff --git a/avconv.c b/avconv.c index 1f8f0476fe..13f943b5b9 100644 --- a/avconv.c +++ b/avconv.c @@ -1615,6 +1615,109 @@ static void rate_emu_sleep(InputStream *ist) } } +static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output) +{ + static unsigned int samples_size = 0; + int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt); + uint8_t *decoded_data_buf = NULL; + int decoded_data_size = 0; + int i, ret; + + if (pkt && samples_size < FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE)) { + av_free(samples); + samples_size = FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE); + samples = av_malloc(samples_size); + } + decoded_data_size = samples_size; + + ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size, + pkt); + if (ret < 0) + return ret; + pkt->data += ret; + pkt->size -= ret; + *got_output = decoded_data_size > 0; + + /* Some bug in mpeg audio decoder gives */ + /* decoded_data_size < 0, it seems they are overflows */ + if (!*got_output) { + /* no audio frame */ + return 0; + } + + decoded_data_buf = (uint8_t *)samples; + ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) / + (ist->st->codec->sample_rate * ist->st->codec->channels); + + // preprocess audio (volume) + if (audio_volume != 256) { + switch (ist->st->codec->sample_fmt) { + case AV_SAMPLE_FMT_U8: + { + uint8_t *volp = samples; + for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { + int v = (((*volp - 128) * audio_volume + 128) >> 8) + 128; + *volp++ = av_clip_uint8(v); + } + break; + } + case AV_SAMPLE_FMT_S16: + { + int16_t *volp = samples; + for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { + int v = ((*volp) * audio_volume + 128) >> 8; + *volp++ = av_clip_int16(v); + } + break; + } + case AV_SAMPLE_FMT_S32: + { + int32_t *volp = samples; + for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { + int64_t v = (((int64_t)*volp * audio_volume + 128) >> 8); + *volp++ = av_clipl_int32(v); + } + break; + } + case AV_SAMPLE_FMT_FLT: + { + float *volp = samples; + float scale = audio_volume / 256.f; + for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { + *volp++ *= scale; + } + break; + } + case AV_SAMPLE_FMT_DBL: + { + double *volp = samples; + double scale = audio_volume / 256.; + for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { + *volp++ *= scale; + } + break; + } + default: + av_log(NULL, AV_LOG_FATAL, + "Audio volume adjustment on sample format %s is not supported.\n", + av_get_sample_fmt_name(ist->st->codec->sample_fmt)); + exit_program(1); + } + } + + rate_emu_sleep(ist); + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = &output_streams[i]; + + if (!check_output_constraints(ist, ost) || !ost->encoding_needed) + continue; + do_audio_out(output_files[ost->file_index].ctx, ost, ist, + decoded_data_buf, decoded_data_size); + } + return 0; +} + /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int output_packet(InputStream *ist, int ist_index, OutputStream *ost_table, int nb_ostreams, @@ -1625,7 +1728,6 @@ static int output_packet(InputStream *ist, int ist_index, int ret = 0, i; int got_output; void *buffer_to_free = NULL; - static unsigned int samples_size= 0; AVSubtitle subtitle, *subtitle_to_free; int64_t pkt_pts = AV_NOPTS_VALUE; #if CONFIG_AVFILTER @@ -1634,7 +1736,6 @@ static int output_packet(InputStream *ist, int ist_index, float quality; AVPacket avpkt; - int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt); if(ist->next_pts == AV_NOPTS_VALUE) ist->next_pts= ist->pts; @@ -1656,8 +1757,6 @@ static int output_packet(InputStream *ist, int ist_index, //while we have more to decode or while the decoder did output something on EOF while (ist->decoding_needed && (avpkt.size > 0 || (!pkt && got_output))) { - uint8_t *decoded_data_buf; - int decoded_data_size; AVFrame *decoded_frame, *filtered_frame; handle_eof: ist->pts= ist->next_pts; @@ -1667,38 +1766,19 @@ static int output_packet(InputStream *ist, int ist_index, "Multiple frames in a packet from stream %d\n", pkt->stream_index); ist->showed_multi_packet_warning=1; - /* decode the packet if needed */ - decoded_frame = filtered_frame = NULL; - decoded_data_buf = NULL; /* fail safe */ - decoded_data_size= 0; - subtitle_to_free = NULL; - switch(ist->st->codec->codec_type) { - case AVMEDIA_TYPE_AUDIO:{ - if(pkt && samples_size < FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE)) { - samples_size = FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE); - av_free(samples); - samples= av_malloc(samples_size); - } - decoded_data_size= samples_size; - /* XXX: could avoid copy if PCM 16 bits with same - endianness as CPU */ - ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size, - &avpkt); + // XXX temporary hack, will be turned to a switch() once all codec + // types are split out + if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { + ret = transcode_audio(ist, &avpkt, &got_output); if (ret < 0) return ret; - avpkt.data += ret; - avpkt.size -= ret; - got_output = decoded_data_size > 0; - /* Some bug in mpeg audio decoder gives */ - /* decoded_data_size < 0, it seems they are overflows */ - if (!got_output) { - /* no audio frame */ - continue; - } - decoded_data_buf = (uint8_t *)samples; - ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) / - (ist->st->codec->sample_rate * ist->st->codec->channels); - break;} + continue; + } + + /* decode the packet if needed */ + decoded_frame = filtered_frame = NULL; + subtitle_to_free = NULL; + switch(ist->st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: if (!(decoded_frame = avcodec_alloc_frame())) return AVERROR(ENOMEM); @@ -1743,64 +1823,6 @@ static int output_packet(InputStream *ist, int ist_index, return -1; } - // preprocess audio (volume) - if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { - if (audio_volume != 256) { - switch (ist->st->codec->sample_fmt) { - case AV_SAMPLE_FMT_U8: - { - uint8_t *volp = samples; - for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { - int v = (((*volp - 128) * audio_volume + 128) >> 8) + 128; - *volp++ = av_clip_uint8(v); - } - break; - } - case AV_SAMPLE_FMT_S16: - { - int16_t *volp = samples; - for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { - int v = ((*volp) * audio_volume + 128) >> 8; - *volp++ = av_clip_int16(v); - } - break; - } - case AV_SAMPLE_FMT_S32: - { - int32_t *volp = samples; - for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { - int64_t v = (((int64_t)*volp * audio_volume + 128) >> 8); - *volp++ = av_clipl_int32(v); - } - break; - } - case AV_SAMPLE_FMT_FLT: - { - float *volp = samples; - float scale = audio_volume / 256.f; - for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { - *volp++ *= scale; - } - break; - } - case AV_SAMPLE_FMT_DBL: - { - double *volp = samples; - double scale = audio_volume / 256.; - for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) { - *volp++ *= scale; - } - break; - } - default: - av_log(NULL, AV_LOG_FATAL, - "Audio volume adjustment on sample format %s is not supported.\n", - av_get_sample_fmt_name(ist->st->codec->sample_fmt)); - exit_program(1); - } - } - } - /* frame rate emulation */ rate_emu_sleep(ist); @@ -1846,9 +1868,6 @@ static int output_packet(InputStream *ist, int ist_index, av_assert0(ist->decoding_needed); switch(ost->st->codec->codec_type) { - case AVMEDIA_TYPE_AUDIO: - do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size); - break; case AVMEDIA_TYPE_VIDEO: #if CONFIG_AVFILTER if (ost->picref->video && !ost->frame_aspect_ratio) From 45d4b66f6fa7115124ae0051dc24cda1017f95a0 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Nov 2011 14:39:22 +0100 Subject: [PATCH 06/22] avconv: split video transcoding out of output_packet(). --- avconv.c | 184 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 100 insertions(+), 84 deletions(-) diff --git a/avconv.c b/avconv.c index 13f943b5b9..409f2bad3d 100644 --- a/avconv.c +++ b/avconv.c @@ -1718,6 +1718,99 @@ static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output) return 0; } +static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *pkt_pts) +{ + AVFrame *decoded_frame, *filtered_frame = NULL; + void *buffer_to_free = NULL; + int i, ret = 0; + float quality; +#if CONFIG_AVFILTER + int frame_available = 1; +#endif + + if (!(decoded_frame = avcodec_alloc_frame())) + return AVERROR(ENOMEM); + pkt->pts = *pkt_pts; + pkt->dts = ist->pts; + *pkt_pts = AV_NOPTS_VALUE; + + ret = avcodec_decode_video2(ist->st->codec, + decoded_frame, got_output, pkt); + if (ret < 0) + goto fail; + + quality = same_quant ? decoded_frame->quality : 0; + if (!*got_output) { + /* no picture yet */ + av_freep(&decoded_frame); + return 0; + } + ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts, + decoded_frame->pkt_dts); + if (ist->st->codec->time_base.num != 0) { + int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : + ist->st->codec->ticks_per_frame; + ist->next_pts += ((int64_t)AV_TIME_BASE * + ist->st->codec->time_base.num * ticks) / + ist->st->codec->time_base.den; + } + pkt->size = 0; + pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free); + + rate_emu_sleep(ist); + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = &output_streams[i]; + int frame_size; + + if (!check_output_constraints(ist, ost) || !ost->encoding_needed) + continue; + +#if CONFIG_AVFILTER + if (ost->input_video_filter) { + AVRational sar; + if (ist->st->sample_aspect_ratio.num) + sar = ist->st->sample_aspect_ratio; + else + sar = ist->st->codec->sample_aspect_ratio; + av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, ist->pts, sar); + if (!(filtered_frame = avcodec_alloc_frame())) { + ret = AVERROR(ENOMEM); + goto fail; + } + frame_available = avfilter_poll_frame(ost->output_video_filter->inputs[0]); + } + while (frame_available) { + AVRational ist_pts_tb; + if (ost->output_video_filter) + get_filtered_video_frame(ost->output_video_filter, filtered_frame, &ost->picref, &ist_pts_tb); + if (ost->picref) + ist->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q); + if (ost->picref->video && !ost->frame_aspect_ratio) + ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect; +#else + filtered_frame = decoded_frame; +#endif + + do_video_out(output_files[ost->file_index].ctx, ost, ist, filtered_frame, &frame_size, + same_quant ? quality : ost->st->codec->global_quality); + if (vstats_filename && frame_size) + do_video_stats(output_files[ost->file_index].ctx, ost, frame_size); +#if CONFIG_AVFILTER + frame_available = ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]); + if (ost->picref) + avfilter_unref_buffer(ost->picref); + } + av_freep(&filtered_frame); +#endif + } + +fail: + av_free(buffer_to_free); + av_freep(&decoded_frame); + return ret; +} + /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int output_packet(InputStream *ist, int ist_index, OutputStream *ost_table, int nb_ostreams, @@ -1727,13 +1820,8 @@ static int output_packet(InputStream *ist, int ist_index, OutputStream *ost; int ret = 0, i; int got_output; - void *buffer_to_free = NULL; AVSubtitle subtitle, *subtitle_to_free; int64_t pkt_pts = AV_NOPTS_VALUE; -#if CONFIG_AVFILTER - int frame_available; -#endif - float quality; AVPacket avpkt; @@ -1757,7 +1845,6 @@ static int output_packet(InputStream *ist, int ist_index, //while we have more to decode or while the decoder did output something on EOF while (ist->decoding_needed && (avpkt.size > 0 || (!pkt && got_output))) { - AVFrame *decoded_frame, *filtered_frame; handle_eof: ist->pts= ist->next_pts; @@ -1773,41 +1860,18 @@ static int output_packet(InputStream *ist, int ist_index, if (ret < 0) return ret; continue; + } else if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + ret = transcode_video(ist, &avpkt, &got_output, &pkt_pts); + if (ret < 0) + return ret; + if (!got_output) + goto discard_packet; + continue; } /* decode the packet if needed */ - decoded_frame = filtered_frame = NULL; subtitle_to_free = NULL; switch(ist->st->codec->codec_type) { - case AVMEDIA_TYPE_VIDEO: - if (!(decoded_frame = avcodec_alloc_frame())) - return AVERROR(ENOMEM); - avpkt.pts = pkt_pts; - avpkt.dts = ist->pts; - pkt_pts = AV_NOPTS_VALUE; - - ret = avcodec_decode_video2(ist->st->codec, - decoded_frame, &got_output, &avpkt); - quality = same_quant ? decoded_frame->quality : 0; - if (ret < 0) - goto fail; - if (!got_output) { - /* no picture yet */ - av_freep(&decoded_frame); - goto discard_packet; - } - ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts, - decoded_frame->pkt_dts); - if (ist->st->codec->time_base.num != 0) { - int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame; - ist->next_pts += ((int64_t)AV_TIME_BASE * - ist->st->codec->time_base.num * ticks) / - ist->st->codec->time_base.den; - } - avpkt.size = 0; - buffer_to_free = NULL; - pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free); - break; case AVMEDIA_TYPE_SUBTITLE: ret = avcodec_decode_subtitle2(ist->st->codec, &subtitle, &got_output, &avpkt); @@ -1829,38 +1893,11 @@ static int output_packet(InputStream *ist, int ist_index, /* if output time reached then transcode raw format, encode packets and output them */ for (i = 0; i < nb_ostreams; i++) { - int frame_size; - ost = &ost_table[i]; if (!check_output_constraints(ist, ost) || !ost->encoding_needed) continue; -#if CONFIG_AVFILTER - if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && - ost->input_video_filter) { - AVRational sar; - if (ist->st->sample_aspect_ratio.num) - sar = ist->st->sample_aspect_ratio; - else - sar = ist->st->codec->sample_aspect_ratio; - av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, ist->pts, sar); - if (!(filtered_frame = avcodec_alloc_frame())) { - ret = AVERROR(ENOMEM); - goto fail; - } - } - frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO || - !ost->output_video_filter || avfilter_poll_frame(ost->output_video_filter->inputs[0]); - while (frame_available) { - AVRational ist_pts_tb; - if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter) - get_filtered_video_frame(ost->output_video_filter, filtered_frame, &ost->picref, &ist_pts_tb); - if (ost->picref) - ist->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q); -#else - filtered_frame = decoded_frame; -#endif os = output_files[ost->file_index].ctx; /* set the input output pts pairs */ @@ -1868,16 +1905,6 @@ static int output_packet(InputStream *ist, int ist_index, av_assert0(ist->decoding_needed); switch(ost->st->codec->codec_type) { - case AVMEDIA_TYPE_VIDEO: -#if CONFIG_AVFILTER - if (ost->picref->video && !ost->frame_aspect_ratio) - ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect; -#endif - do_video_out(os, ost, ist, filtered_frame, &frame_size, - same_quant ? quality : ost->st->codec->global_quality); - if (vstats_filename && frame_size) - do_video_stats(os, ost, frame_size); - break; case AVMEDIA_TYPE_SUBTITLE: do_subtitle_out(os, ost, ist, &subtitle, pkt->pts); @@ -1885,24 +1912,13 @@ static int output_packet(InputStream *ist, int ist_index, default: abort(); } -#if CONFIG_AVFILTER - frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && - ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]); - if (ost->picref) - avfilter_unref_buffer(ost->picref); - } - av_freep(&filtered_frame); -#endif } -fail: - av_free(buffer_to_free); /* XXX: allocate the subtitles in the codec ? */ if (subtitle_to_free) { avsubtitle_free(subtitle_to_free); subtitle_to_free = NULL; } - av_freep(&decoded_frame); if (ret < 0) return ret; } From 9595234c941cb81ffc2858e3f5859f0b9fa58a39 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Nov 2011 14:39:22 +0100 Subject: [PATCH 07/22] avconv: split subtitle transcoding out of output_packet(). --- avconv.c | 59 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/avconv.c b/avconv.c index 409f2bad3d..4a5fb9c0bb 100644 --- a/avconv.c +++ b/avconv.c @@ -1811,16 +1811,41 @@ fail: return ret; } +static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) +{ + AVSubtitle subtitle; + int i, ret = avcodec_decode_subtitle2(ist->st->codec, + &subtitle, got_output, pkt); + if (ret < 0) + return ret; + if (!*got_output) + return 0; + + pkt->size = 0; + + rate_emu_sleep(ist); + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = &output_streams[i]; + + if (!check_output_constraints(ist, ost) || !ost->encoding_needed) + continue; + + do_subtitle_out(output_files[ost->file_index].ctx, ost, ist, &subtitle, pkt->pts); + } + + avsubtitle_free(&subtitle); + return 0; +} + /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int output_packet(InputStream *ist, int ist_index, OutputStream *ost_table, int nb_ostreams, const AVPacket *pkt) { - AVFormatContext *os; OutputStream *ost; int ret = 0, i; int got_output; - AVSubtitle subtitle, *subtitle_to_free; int64_t pkt_pts = AV_NOPTS_VALUE; AVPacket avpkt; @@ -1867,22 +1892,17 @@ static int output_packet(InputStream *ist, int ist_index, if (!got_output) goto discard_packet; continue; + } else if (ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { + ret = transcode_subtitles(ist, &avpkt, &got_output); + if (ret < 0) + return ret; + if (!got_output) + goto discard_packet; + continue; } /* decode the packet if needed */ - subtitle_to_free = NULL; switch(ist->st->codec->codec_type) { - case AVMEDIA_TYPE_SUBTITLE: - ret = avcodec_decode_subtitle2(ist->st->codec, - &subtitle, &got_output, &avpkt); - if (ret < 0) - return ret; - if (!got_output) { - goto discard_packet; - } - subtitle_to_free = &subtitle; - avpkt.size = 0; - break; default: return -1; } @@ -1898,27 +1918,16 @@ static int output_packet(InputStream *ist, int ist_index, if (!check_output_constraints(ist, ost) || !ost->encoding_needed) continue; - os = output_files[ost->file_index].ctx; - /* set the input output pts pairs */ //ost->sync_ipts = (double)(ist->pts + input_files[ist->file_index].ts_offset - start_time)/ AV_TIME_BASE; av_assert0(ist->decoding_needed); switch(ost->st->codec->codec_type) { - case AVMEDIA_TYPE_SUBTITLE: - do_subtitle_out(os, ost, ist, &subtitle, - pkt->pts); - break; default: abort(); } } - /* XXX: allocate the subtitles in the codec ? */ - if (subtitle_to_free) { - avsubtitle_free(subtitle_to_free); - subtitle_to_free = NULL; - } if (ret < 0) return ret; } From 82963f8f046bbe724e6c770a2aaf0290c9915503 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Nov 2011 15:37:40 +0100 Subject: [PATCH 08/22] avconv: cleanup the transcoding loop in output_packet(). --- avconv.c | 59 ++++++++++++++------------------------------------------ 1 file changed, 14 insertions(+), 45 deletions(-) diff --git a/avconv.c b/avconv.c index 4a5fb9c0bb..a87f852444 100644 --- a/avconv.c +++ b/avconv.c @@ -1878,58 +1878,27 @@ static int output_packet(InputStream *ist, int ist_index, "Multiple frames in a packet from stream %d\n", pkt->stream_index); ist->showed_multi_packet_warning=1; - // XXX temporary hack, will be turned to a switch() once all codec - // types are split out - if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { - ret = transcode_audio(ist, &avpkt, &got_output); - if (ret < 0) - return ret; - continue; - } else if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { - ret = transcode_video(ist, &avpkt, &got_output, &pkt_pts); - if (ret < 0) - return ret; - if (!got_output) - goto discard_packet; - continue; - } else if (ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { - ret = transcode_subtitles(ist, &avpkt, &got_output); - if (ret < 0) - return ret; - if (!got_output) - goto discard_packet; - continue; - } - - /* decode the packet if needed */ switch(ist->st->codec->codec_type) { + case AVMEDIA_TYPE_AUDIO: + ret = transcode_audio (ist, &avpkt, &got_output); + break; + case AVMEDIA_TYPE_VIDEO: + ret = transcode_video (ist, &avpkt, &got_output, &pkt_pts); + break; + case AVMEDIA_TYPE_SUBTITLE: + ret = transcode_subtitles(ist, &avpkt, &got_output); + break; default: return -1; } - /* frame rate emulation */ - rate_emu_sleep(ist); - - /* if output time reached then transcode raw format, - encode packets and output them */ - for (i = 0; i < nb_ostreams; i++) { - ost = &ost_table[i]; - - if (!check_output_constraints(ist, ost) || !ost->encoding_needed) - continue; - - /* set the input output pts pairs */ - //ost->sync_ipts = (double)(ist->pts + input_files[ist->file_index].ts_offset - start_time)/ AV_TIME_BASE; - - av_assert0(ist->decoding_needed); - switch(ost->st->codec->codec_type) { - default: - abort(); - } - } - if (ret < 0) return ret; + if (!got_output) { + if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) + continue; + goto discard_packet; + } } discard_packet: From 0945eddec09d1c2b69643afc70377d86febc0591 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Thu, 10 Nov 2011 17:30:33 +0100 Subject: [PATCH 09/22] pthread: do not touch has_b_frames Adding the thread count in frame level multithreading to has_b_frames as an additional delay causes more problems than it solves. For example inconsistent behaviour during timestamp calculation in libavformat. Thread count and frame level multithreading are both set by the user. If the additional delay caused by frame level multithreading needs to be considered in the calling code it has all information to take it into account. Should it become necessary to calculate a maximum delay inside libavcodec it should be exported as its own field and not reusing an existing field. Based on a patch by Michael Niedermayer. Signed-off-by: Janne Grunau --- libavcodec/pthread.c | 4 +--- libavcodec/version.h | 2 +- libavformat/utils.c | 5 ----- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 42b82a57d7..9c3453f13d 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -363,8 +363,7 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, } if (for_user) { - dst->coded_frame = src->coded_frame; - dst->has_b_frames += src->thread_count - 1; + dst->coded_frame = src->coded_frame; } else { if (dst->codec->update_thread_context) err = dst->codec->update_thread_context(dst, src); @@ -684,7 +683,6 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count) av_freep(&fctx->threads); pthread_mutex_destroy(&fctx->buffer_mutex); av_freep(&avctx->thread_opaque); - avctx->has_b_frames -= avctx->thread_count - 1; } static int frame_thread_init(AVCodecContext *avctx) diff --git a/libavcodec/version.h b/libavcodec/version.h index 35e8958c69..3f5c42e33e 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -21,7 +21,7 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 21 +#define LIBAVCODEC_VERSION_MINOR 22 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavformat/utils.c b/libavformat/utils.c index b8262ecaf1..2b378ab712 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -964,11 +964,6 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, delay= st->codec->has_b_frames; presentation_delayed = 0; - // ignore delay caused by frame threading so that the mpeg2-without-dts - // warning will not trigger - if (delay && st->codec->active_thread_type&FF_THREAD_FRAME) - delay -= st->codec->thread_count-1; - /* XXX: need has_b_frame, but cannot get it if the codec is not initialized */ if (delay && From 8ee2b4672f6ad5cfd003e742f887cffcfea26021 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 15 Nov 2011 01:15:52 +0000 Subject: [PATCH 10/22] ARM: add explicit .arch and .fpu directives to asm.S This prevents build errors when compiler and assembler default targets differ. Ideally each file would declare the highest level it requires. This is however not easily possible as it complicates assembling pre-armv6t2 code in Thumb-2 mode. HAVE_NEON is used as indicator for ARMv7-A since no other symbol exists for this and NEON is only available in this variant. Signed-off-by: Mans Rullgard --- libavcodec/arm/asm.S | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libavcodec/arm/asm.S b/libavcodec/arm/asm.S index a7d3ace208..a124918c1c 100644 --- a/libavcodec/arm/asm.S +++ b/libavcodec/arm/asm.S @@ -34,6 +34,22 @@ # define T @ #endif +#if HAVE_NEON + .arch armv7-a +#elif HAVE_ARMV6T2 + .arch armv6t2 +#elif HAVE_ARMV6 + .arch armv6 +#elif HAVE_ARMV5TE + .arch armv5te +#endif + +#if HAVE_NEON + .fpu neon +#elif HAVE_ARMVFP + .fpu vfp +#endif + .syntax unified T .thumb From 3fe5fc93258bfab00251ff99f75a7586976562c3 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 21 Nov 2011 23:02:32 +0000 Subject: [PATCH 11/22] regtest: split video encode/decode tests into individual targets Signed-off-by: Mans Rullgard --- configure | 8 +++++--- tests/codec-regression.sh | 20 ++++++++++++++++++- .../seek/{mpeg2_mpg => mpeg2_idct_int_mpg} | 0 tests/ref/vsynth1/dv | 4 ---- tests/ref/vsynth1/dv_411 | 4 ++++ tests/ref/vsynth1/mpeg2 | 16 --------------- tests/ref/vsynth1/mpeg2_422 | 4 ++++ tests/ref/vsynth1/mpeg2_idct_int | 4 ++++ tests/ref/vsynth1/mpeg2_ilace | 4 ++++ tests/ref/vsynth1/mpeg2_ivlc_qprd | 4 ++++ tests/ref/vsynth1/mpeg2thread | 4 ---- tests/ref/vsynth1/mpeg2thread_ilace | 4 ++++ tests/ref/vsynth1/mpeg4_adap | 4 ++++ tests/ref/vsynth1/mpeg4_qpel | 4 ++++ tests/ref/vsynth1/mpeg4_qprd | 4 ++++ tests/ref/vsynth1/mpeg4adv | 12 ----------- tests/ref/vsynth2/dv | 4 ---- tests/ref/vsynth2/dv_411 | 4 ++++ tests/ref/vsynth2/mpeg2 | 16 --------------- tests/ref/vsynth2/mpeg2_422 | 4 ++++ tests/ref/vsynth2/mpeg2_idct_int | 4 ++++ tests/ref/vsynth2/mpeg2_ilace | 4 ++++ tests/ref/vsynth2/mpeg2_ivlc_qprd | 4 ++++ tests/ref/vsynth2/mpeg2thread | 4 ---- tests/ref/vsynth2/mpeg2thread_ilace | 4 ++++ tests/ref/vsynth2/mpeg4_adap | 4 ++++ tests/ref/vsynth2/mpeg4_qpel | 4 ++++ tests/ref/vsynth2/mpeg4_qprd | 4 ++++ tests/ref/vsynth2/mpeg4adv | 12 ----------- 29 files changed, 96 insertions(+), 76 deletions(-) rename tests/ref/seek/{mpeg2_mpg => mpeg2_idct_int_mpg} (100%) create mode 100644 tests/ref/vsynth1/dv_411 create mode 100644 tests/ref/vsynth1/mpeg2_422 create mode 100644 tests/ref/vsynth1/mpeg2_idct_int create mode 100644 tests/ref/vsynth1/mpeg2_ilace create mode 100644 tests/ref/vsynth1/mpeg2_ivlc_qprd create mode 100644 tests/ref/vsynth1/mpeg2thread_ilace create mode 100644 tests/ref/vsynth1/mpeg4_adap create mode 100644 tests/ref/vsynth1/mpeg4_qpel create mode 100644 tests/ref/vsynth1/mpeg4_qprd create mode 100644 tests/ref/vsynth2/dv_411 create mode 100644 tests/ref/vsynth2/mpeg2_422 create mode 100644 tests/ref/vsynth2/mpeg2_idct_int create mode 100644 tests/ref/vsynth2/mpeg2_ilace create mode 100644 tests/ref/vsynth2/mpeg2_ivlc_qprd create mode 100644 tests/ref/vsynth2/mpeg2thread_ilace create mode 100644 tests/ref/vsynth2/mpeg4_adap create mode 100644 tests/ref/vsynth2/mpeg4_qpel create mode 100644 tests/ref/vsynth2/mpeg4_qprd diff --git a/configure b/configure index 38fe904e49..57630f2a53 100755 --- a/configure +++ b/configure @@ -1556,7 +1556,7 @@ test_deps _encoder _decoder \ asv2 \ bmp \ dnxhd="dnxhd_1080i dnxhd_720p dnxhd_720p_rd" \ - dvvideo="dv dv50" \ + dvvideo="dv dv_411 dv50" \ ffv1 \ flac \ flashsv \ @@ -1569,8 +1569,10 @@ test_deps _encoder _decoder \ mjpeg="jpg mjpeg ljpeg" \ mp2 \ mpeg1video="mpeg mpeg1b" \ - mpeg2video="mpeg2 mpeg2thread" \ - mpeg4="mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc" \ + mpeg2video="mpeg2 mpeg2_422 mpeg2_idct_int mpeg2_ilace mpeg2_ivlc_qprd" \ + mpeg2video="mpeg2thread mpeg2thread_ilace" \ + mpeg4="mpeg4 mpeg4_adap mpeg4_qpel mpeg4_qprd mpeg4adv mpeg4nr" \ + mpeg4="mpeg4thread error rc" \ msmpeg4v3=msmpeg4 \ msmpeg4v2 \ pbm=pbmpipe \ diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index 38d641a197..1a15c39e67 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -29,19 +29,27 @@ if [ -n "$do_mpeg2" ] ; then # mpeg2 do_video_encoding mpeg2.mpg "-qscale 10 -vcodec mpeg2video -f mpeg1video" do_video_decoding +fi +if [ -n "$do_mpeg2_ivlc_qprd" ]; then # mpeg2 encoding intra vlc qprd do_video_encoding mpeg2ivlc-qprd.mpg "-vb 500k -bf 2 -trellis 1 -flags +qprd+mv0 -flags2 +ivlc -cmp 2 -subcmp 2 -mbd rd -vcodec mpeg2video -f mpeg2video" do_video_decoding +fi +if [ -n "$do_mpeg2_422" ]; then #mpeg2 4:2:2 encoding do_video_encoding mpeg2_422.mpg "-vb 1000k -bf 2 -trellis 1 -flags +qprd+mv0+ildct+ilme -flags2 +ivlc -mbd rd -vcodec mpeg2video -pix_fmt yuv422p -f mpeg2video" do_video_decoding +fi +if [ -n "$do_mpeg2_idct_int" ]; then # mpeg2 -do_video_encoding mpeg2.mpg "-qscale 10 -vcodec mpeg2video -idct int -dct int -f mpeg1video" +do_video_encoding mpeg2_idct_int.mpg "-qscale 10 -vcodec mpeg2video -idct int -dct int -f mpeg1video" do_video_decoding "-idct int" +fi +if [ -n "$do_mpeg2_ilace" ]; then # mpeg2 encoding interlaced do_video_encoding mpeg2i.mpg "-qscale 10 -vcodec mpeg2video -f mpeg1video -flags +ildct+ilme" do_video_decoding @@ -51,7 +59,9 @@ if [ -n "$do_mpeg2thread" ] ; then # mpeg2 encoding interlaced do_video_encoding mpeg2thread.mpg "-qscale 10 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 2" do_video_decoding +fi +if [ -n "$do_mpeg2thread_ilace" ]; then # mpeg2 encoding interlaced using intra vlc do_video_encoding mpeg2threadivlc.mpg "-qscale 10 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -flags2 +ivlc -threads 2" do_video_decoding @@ -110,13 +120,19 @@ fi if [ -n "$do_mpeg4adv" ] ; then do_video_encoding mpeg4-adv.avi "-qscale 9 -flags +mv4+part+aic -trellis 1 -mbd bits -ps 200 -an -vcodec mpeg4" do_video_decoding +fi +if [ -n "$do_mpeg4_qprd" ]; then do_video_encoding mpeg4-qprd.avi "-b 450k -bf 2 -trellis 1 -flags +mv4+qprd+mv0 -cmp 2 -subcmp 2 -mbd rd -an -vcodec mpeg4" do_video_decoding +fi +if [ -n "$do_mpeg4_adap" ]; then do_video_encoding mpeg4-adap.avi "-b 550k -bf 2 -flags +mv4+mv0 -trellis 1 -cmp 1 -subcmp 2 -mbd rd -scplx_mask 0.3 -an -vcodec mpeg4" do_video_decoding +fi +if [ -n "$do_mpeg4_qpel" ]; then do_video_encoding mpeg4-Q.avi "-qscale 7 -flags +mv4+qpel -mbd 2 -bf 2 -cmp 1 -subcmp 2 -an -vcodec mpeg4" do_video_decoding fi @@ -199,7 +215,9 @@ fi if [ -n "$do_dv" ] ; then do_video_encoding dv.dv "-dct int -s pal -an" do_video_decoding "" "-s cif" +fi +if [ -n "$do_dv_411" ]; then do_video_encoding dv411.dv "-dct int -s pal -an -pix_fmt yuv411p -sws_flags area+accurate_rnd+bitexact" do_video_decoding "" "-s cif -sws_flags area+accurate_rnd+bitexact" fi diff --git a/tests/ref/seek/mpeg2_mpg b/tests/ref/seek/mpeg2_idct_int_mpg similarity index 100% rename from tests/ref/seek/mpeg2_mpg rename to tests/ref/seek/mpeg2_idct_int_mpg diff --git a/tests/ref/vsynth1/dv b/tests/ref/vsynth1/dv index cb0427c558..c309bb2aba 100644 --- a/tests/ref/vsynth1/dv +++ b/tests/ref/vsynth1/dv @@ -2,7 +2,3 @@ 7200000 ./tests/data/vsynth1/dv.dv 02ac7cdeab91d4d5621e7ce96dddc498 *./tests/data/dv.vsynth1.out.yuv stddev: 6.90 PSNR: 31.34 MAXDIFF: 76 bytes: 7603200/ 7603200 -bd67f2431db160d4bb6dcd791cea6efd *./tests/data/vsynth1/dv411.dv -7200000 ./tests/data/vsynth1/dv411.dv -b6640a3a572353f51284acb746eb00c4 *./tests/data/dv.vsynth1.out.yuv -stddev: 30.76 PSNR: 18.37 MAXDIFF: 205 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/dv_411 b/tests/ref/vsynth1/dv_411 new file mode 100644 index 0000000000..841c3fd326 --- /dev/null +++ b/tests/ref/vsynth1/dv_411 @@ -0,0 +1,4 @@ +bd67f2431db160d4bb6dcd791cea6efd *./tests/data/vsynth1/dv411.dv +7200000 ./tests/data/vsynth1/dv411.dv +b6640a3a572353f51284acb746eb00c4 *./tests/data/dv_411.vsynth1.out.yuv +stddev: 30.76 PSNR: 18.37 MAXDIFF: 205 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg2 b/tests/ref/vsynth1/mpeg2 index e6d404dc09..0df3b7f248 100644 --- a/tests/ref/vsynth1/mpeg2 +++ b/tests/ref/vsynth1/mpeg2 @@ -2,19 +2,3 @@ fbddea2368cd2028fc8db4dfd4682e94 *./tests/data/vsynth1/mpeg2.mpg 728044 ./tests/data/vsynth1/mpeg2.mpg b41ca49c1a02e66ce64d262e2cdaec15 *./tests/data/mpeg2.vsynth1.out.yuv stddev: 7.65 PSNR: 30.45 MAXDIFF: 84 bytes: 7603200/ 7603200 -8f6b20714918e6443e0c03716ed06f0d *./tests/data/vsynth1/mpeg2ivlc-qprd.mpg -783552 ./tests/data/vsynth1/mpeg2ivlc-qprd.mpg -98eb9da15f880978e7f2ee1e7ce476ef *./tests/data/mpeg2.vsynth1.out.yuv -stddev: 10.07 PSNR: 28.06 MAXDIFF: 165 bytes: 7603200/ 7603200 -af0cb75451aaa807beb5102707a98823 *./tests/data/vsynth1/mpeg2_422.mpg -728200 ./tests/data/vsynth1/mpeg2_422.mpg -29b518282493203e83b27a939795dc3a *./tests/data/mpeg2.vsynth1.out.yuv -stddev: 63.33 PSNR: 12.10 MAXDIFF: 242 bytes: 10137600/ 7603200 -4c067397b504d65532d7779cd36f3f88 *./tests/data/vsynth1/mpeg2.mpg -725668 ./tests/data/vsynth1/mpeg2.mpg -9f7b065f98d57cdecf90e6f7a2524eb5 *./tests/data/mpeg2.vsynth1.out.yuv -stddev: 7.65 PSNR: 30.45 MAXDIFF: 81 bytes: 7603200/ 7603200 -ec3f6713c88a2b41f6c369fd64341077 *./tests/data/vsynth1/mpeg2i.mpg -737473 ./tests/data/vsynth1/mpeg2i.mpg -97615390fdd69abfcbc7e02df863a7d2 *./tests/data/mpeg2.vsynth1.out.yuv -stddev: 7.67 PSNR: 30.43 MAXDIFF: 84 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg2_422 b/tests/ref/vsynth1/mpeg2_422 new file mode 100644 index 0000000000..beef80bdfd --- /dev/null +++ b/tests/ref/vsynth1/mpeg2_422 @@ -0,0 +1,4 @@ +af0cb75451aaa807beb5102707a98823 *./tests/data/vsynth1/mpeg2_422.mpg +728200 ./tests/data/vsynth1/mpeg2_422.mpg +29b518282493203e83b27a939795dc3a *./tests/data/mpeg2_422.vsynth1.out.yuv +stddev: 63.33 PSNR: 12.10 MAXDIFF: 242 bytes: 10137600/ 7603200 diff --git a/tests/ref/vsynth1/mpeg2_idct_int b/tests/ref/vsynth1/mpeg2_idct_int new file mode 100644 index 0000000000..be73750373 --- /dev/null +++ b/tests/ref/vsynth1/mpeg2_idct_int @@ -0,0 +1,4 @@ +4c067397b504d65532d7779cd36f3f88 *./tests/data/vsynth1/mpeg2_idct_int.mpg +725668 ./tests/data/vsynth1/mpeg2_idct_int.mpg +9f7b065f98d57cdecf90e6f7a2524eb5 *./tests/data/mpeg2_idct_int.vsynth1.out.yuv +stddev: 7.65 PSNR: 30.45 MAXDIFF: 81 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg2_ilace b/tests/ref/vsynth1/mpeg2_ilace new file mode 100644 index 0000000000..e05951fc64 --- /dev/null +++ b/tests/ref/vsynth1/mpeg2_ilace @@ -0,0 +1,4 @@ +ec3f6713c88a2b41f6c369fd64341077 *./tests/data/vsynth1/mpeg2i.mpg +737473 ./tests/data/vsynth1/mpeg2i.mpg +97615390fdd69abfcbc7e02df863a7d2 *./tests/data/mpeg2_ilace.vsynth1.out.yuv +stddev: 7.67 PSNR: 30.43 MAXDIFF: 84 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg2_ivlc_qprd b/tests/ref/vsynth1/mpeg2_ivlc_qprd new file mode 100644 index 0000000000..c8a6694d82 --- /dev/null +++ b/tests/ref/vsynth1/mpeg2_ivlc_qprd @@ -0,0 +1,4 @@ +8f6b20714918e6443e0c03716ed06f0d *./tests/data/vsynth1/mpeg2ivlc-qprd.mpg +783552 ./tests/data/vsynth1/mpeg2ivlc-qprd.mpg +98eb9da15f880978e7f2ee1e7ce476ef *./tests/data/mpeg2_ivlc_qprd.vsynth1.out.yuv +stddev: 10.07 PSNR: 28.06 MAXDIFF: 165 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg2thread b/tests/ref/vsynth1/mpeg2thread index e32007cfcd..a44c00dd91 100644 --- a/tests/ref/vsynth1/mpeg2thread +++ b/tests/ref/vsynth1/mpeg2thread @@ -2,7 +2,3 @@ ecd183706688bd977c9994c3d1b23d61 *./tests/data/vsynth1/mpeg2thread.mpg 801313 ./tests/data/vsynth1/mpeg2thread.mpg d1658911ca83f5616c1d32abc40750de *./tests/data/mpeg2thread.vsynth1.out.yuv stddev: 7.63 PSNR: 30.48 MAXDIFF: 110 bytes: 7603200/ 7603200 -23d600b026222253c2340e23300a4c02 *./tests/data/vsynth1/mpeg2threadivlc.mpg -791773 ./tests/data/vsynth1/mpeg2threadivlc.mpg -d1658911ca83f5616c1d32abc40750de *./tests/data/mpeg2thread.vsynth1.out.yuv -stddev: 7.63 PSNR: 30.48 MAXDIFF: 110 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg2thread_ilace b/tests/ref/vsynth1/mpeg2thread_ilace new file mode 100644 index 0000000000..0667b68fae --- /dev/null +++ b/tests/ref/vsynth1/mpeg2thread_ilace @@ -0,0 +1,4 @@ +23d600b026222253c2340e23300a4c02 *./tests/data/vsynth1/mpeg2threadivlc.mpg +791773 ./tests/data/vsynth1/mpeg2threadivlc.mpg +d1658911ca83f5616c1d32abc40750de *./tests/data/mpeg2thread_ilace.vsynth1.out.yuv +stddev: 7.63 PSNR: 30.48 MAXDIFF: 110 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg4_adap b/tests/ref/vsynth1/mpeg4_adap new file mode 100644 index 0000000000..7513a22f08 --- /dev/null +++ b/tests/ref/vsynth1/mpeg4_adap @@ -0,0 +1,4 @@ +2d870c0da9ab2231ab5fc06981e70399 *./tests/data/vsynth1/mpeg4-adap.avi +403456 ./tests/data/vsynth1/mpeg4-adap.avi +fa2049396479b5f170aa764fed5b2a31 *./tests/data/mpeg4_adap.vsynth1.out.yuv +stddev: 14.05 PSNR: 25.17 MAXDIFF: 184 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg4_qpel b/tests/ref/vsynth1/mpeg4_qpel new file mode 100644 index 0000000000..51547d8038 --- /dev/null +++ b/tests/ref/vsynth1/mpeg4_qpel @@ -0,0 +1,4 @@ +3bf17c3d04f52988386ce106a2a58976 *./tests/data/vsynth1/mpeg4-Q.avi +860678 ./tests/data/vsynth1/mpeg4-Q.avi +756928496245ecc701f79eebeec8e5e6 *./tests/data/mpeg4_qpel.vsynth1.out.yuv +stddev: 5.63 PSNR: 33.12 MAXDIFF: 70 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg4_qprd b/tests/ref/vsynth1/mpeg4_qprd new file mode 100644 index 0000000000..aa3b506a76 --- /dev/null +++ b/tests/ref/vsynth1/mpeg4_qprd @@ -0,0 +1,4 @@ +d6b7e724a6ad66ab5e4c5a499218b40d *./tests/data/vsynth1/mpeg4-qprd.avi +710944 ./tests/data/vsynth1/mpeg4-qprd.avi +e65f4c7f343fe2bad1cac44b7da5f7c4 *./tests/data/mpeg4_qprd.vsynth1.out.yuv +stddev: 9.79 PSNR: 28.31 MAXDIFF: 176 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth1/mpeg4adv b/tests/ref/vsynth1/mpeg4adv index d61431028a..374f0b206e 100644 --- a/tests/ref/vsynth1/mpeg4adv +++ b/tests/ref/vsynth1/mpeg4adv @@ -2,15 +2,3 @@ 589716 ./tests/data/vsynth1/mpeg4-adv.avi f8b226876b1b2c0b98fd6928fd9adbd8 *./tests/data/mpeg4adv.vsynth1.out.yuv stddev: 6.98 PSNR: 31.25 MAXDIFF: 84 bytes: 7603200/ 7603200 -d6b7e724a6ad66ab5e4c5a499218b40d *./tests/data/vsynth1/mpeg4-qprd.avi -710944 ./tests/data/vsynth1/mpeg4-qprd.avi -e65f4c7f343fe2bad1cac44b7da5f7c4 *./tests/data/mpeg4adv.vsynth1.out.yuv -stddev: 9.79 PSNR: 28.31 MAXDIFF: 176 bytes: 7603200/ 7603200 -2d870c0da9ab2231ab5fc06981e70399 *./tests/data/vsynth1/mpeg4-adap.avi -403456 ./tests/data/vsynth1/mpeg4-adap.avi -fa2049396479b5f170aa764fed5b2a31 *./tests/data/mpeg4adv.vsynth1.out.yuv -stddev: 14.05 PSNR: 25.17 MAXDIFF: 184 bytes: 7603200/ 7603200 -3bf17c3d04f52988386ce106a2a58976 *./tests/data/vsynth1/mpeg4-Q.avi -860678 ./tests/data/vsynth1/mpeg4-Q.avi -756928496245ecc701f79eebeec8e5e6 *./tests/data/mpeg4adv.vsynth1.out.yuv -stddev: 5.63 PSNR: 33.12 MAXDIFF: 70 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/dv b/tests/ref/vsynth2/dv index 676b209c58..6c010b9301 100644 --- a/tests/ref/vsynth2/dv +++ b/tests/ref/vsynth2/dv @@ -2,7 +2,3 @@ bfa766f89bfeabc0ae1044f3954bed52 *./tests/data/vsynth2/dv.dv 7200000 ./tests/data/vsynth2/dv.dv 7ec62bd3350a6848364669e6e1e4b9cc *./tests/data/dv.vsynth2.out.yuv stddev: 1.71 PSNR: 43.47 MAXDIFF: 33 bytes: 7603200/ 7603200 -00a9d8683ac6826af41bcf7223fb0389 *./tests/data/vsynth2/dv411.dv -7200000 ./tests/data/vsynth2/dv411.dv -7f9fa421028aabb11eaf4c6513a5a843 *./tests/data/dv.vsynth2.out.yuv -stddev: 10.09 PSNR: 28.05 MAXDIFF: 60 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/dv_411 b/tests/ref/vsynth2/dv_411 new file mode 100644 index 0000000000..2340ef0e7e --- /dev/null +++ b/tests/ref/vsynth2/dv_411 @@ -0,0 +1,4 @@ +00a9d8683ac6826af41bcf7223fb0389 *./tests/data/vsynth2/dv411.dv +7200000 ./tests/data/vsynth2/dv411.dv +7f9fa421028aabb11eaf4c6513a5a843 *./tests/data/dv_411.vsynth2.out.yuv +stddev: 10.09 PSNR: 28.05 MAXDIFF: 60 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg2 b/tests/ref/vsynth2/mpeg2 index a6ab3f6b90..5232eea988 100644 --- a/tests/ref/vsynth2/mpeg2 +++ b/tests/ref/vsynth2/mpeg2 @@ -2,19 +2,3 @@ 198667 ./tests/data/vsynth2/mpeg2.mpg b7cae8a1f751b821cddcbe4d5dbc518c *./tests/data/mpeg2.vsynth2.out.yuv stddev: 4.96 PSNR: 34.20 MAXDIFF: 59 bytes: 7603200/ 7603200 -1ba5efeb53fab7b4b71edc96d86f6c91 *./tests/data/vsynth2/mpeg2ivlc-qprd.mpg -244694 ./tests/data/vsynth2/mpeg2ivlc-qprd.mpg -b26e21599dee48a174bdbc40b2817e55 *./tests/data/mpeg2.vsynth2.out.yuv -stddev: 4.15 PSNR: 35.76 MAXDIFF: 74 bytes: 7603200/ 7603200 -2c8e33c2d2efab86fc16a195f6877682 *./tests/data/vsynth2/mpeg2_422.mpg -356124 ./tests/data/vsynth2/mpeg2_422.mpg -de44597c6c470f3e7019b31245a3ff69 *./tests/data/mpeg2.vsynth2.out.yuv -stddev: 54.55 PSNR: 13.39 MAXDIFF: 201 bytes: 10137600/ 7603200 -f979bcca866e6e4cad5dc6cb06e56cfb *./tests/data/vsynth2/mpeg2.mpg -198041 ./tests/data/vsynth2/mpeg2.mpg -f6d9bf24ff8676a7f6076c05cd2c81a3 *./tests/data/mpeg2.vsynth2.out.yuv -stddev: 4.97 PSNR: 34.19 MAXDIFF: 58 bytes: 7603200/ 7603200 -f90197a8b6e62ae25f82625337f27240 *./tests/data/vsynth2/mpeg2i.mpg -204579 ./tests/data/vsynth2/mpeg2i.mpg -ea5057b60146c06d40449cdfc686bf13 *./tests/data/mpeg2.vsynth2.out.yuv -stddev: 4.98 PSNR: 34.18 MAXDIFF: 65 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg2_422 b/tests/ref/vsynth2/mpeg2_422 new file mode 100644 index 0000000000..c4e28dd0d4 --- /dev/null +++ b/tests/ref/vsynth2/mpeg2_422 @@ -0,0 +1,4 @@ +2c8e33c2d2efab86fc16a195f6877682 *./tests/data/vsynth2/mpeg2_422.mpg +356124 ./tests/data/vsynth2/mpeg2_422.mpg +de44597c6c470f3e7019b31245a3ff69 *./tests/data/mpeg2_422.vsynth2.out.yuv +stddev: 54.55 PSNR: 13.39 MAXDIFF: 201 bytes: 10137600/ 7603200 diff --git a/tests/ref/vsynth2/mpeg2_idct_int b/tests/ref/vsynth2/mpeg2_idct_int new file mode 100644 index 0000000000..9900497868 --- /dev/null +++ b/tests/ref/vsynth2/mpeg2_idct_int @@ -0,0 +1,4 @@ +f979bcca866e6e4cad5dc6cb06e56cfb *./tests/data/vsynth2/mpeg2_idct_int.mpg +198041 ./tests/data/vsynth2/mpeg2_idct_int.mpg +f6d9bf24ff8676a7f6076c05cd2c81a3 *./tests/data/mpeg2_idct_int.vsynth2.out.yuv +stddev: 4.97 PSNR: 34.19 MAXDIFF: 58 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg2_ilace b/tests/ref/vsynth2/mpeg2_ilace new file mode 100644 index 0000000000..99d80a4fef --- /dev/null +++ b/tests/ref/vsynth2/mpeg2_ilace @@ -0,0 +1,4 @@ +f90197a8b6e62ae25f82625337f27240 *./tests/data/vsynth2/mpeg2i.mpg +204579 ./tests/data/vsynth2/mpeg2i.mpg +ea5057b60146c06d40449cdfc686bf13 *./tests/data/mpeg2_ilace.vsynth2.out.yuv +stddev: 4.98 PSNR: 34.18 MAXDIFF: 65 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg2_ivlc_qprd b/tests/ref/vsynth2/mpeg2_ivlc_qprd new file mode 100644 index 0000000000..d8aa1ab659 --- /dev/null +++ b/tests/ref/vsynth2/mpeg2_ivlc_qprd @@ -0,0 +1,4 @@ +1ba5efeb53fab7b4b71edc96d86f6c91 *./tests/data/vsynth2/mpeg2ivlc-qprd.mpg +244694 ./tests/data/vsynth2/mpeg2ivlc-qprd.mpg +b26e21599dee48a174bdbc40b2817e55 *./tests/data/mpeg2_ivlc_qprd.vsynth2.out.yuv +stddev: 4.15 PSNR: 35.76 MAXDIFF: 74 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg2thread b/tests/ref/vsynth2/mpeg2thread index 6d86735254..7d7ed218c6 100644 --- a/tests/ref/vsynth2/mpeg2thread +++ b/tests/ref/vsynth2/mpeg2thread @@ -2,7 +2,3 @@ 179650 ./tests/data/vsynth2/mpeg2thread.mpg 8c6a7ed2eb73bd18fd2bb9829464100d *./tests/data/mpeg2thread.vsynth2.out.yuv stddev: 4.72 PSNR: 34.65 MAXDIFF: 72 bytes: 7603200/ 7603200 -10b900e32809758857c596d56746e00e *./tests/data/vsynth2/mpeg2threadivlc.mpg -178801 ./tests/data/vsynth2/mpeg2threadivlc.mpg -8c6a7ed2eb73bd18fd2bb9829464100d *./tests/data/mpeg2thread.vsynth2.out.yuv -stddev: 4.72 PSNR: 34.65 MAXDIFF: 72 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg2thread_ilace b/tests/ref/vsynth2/mpeg2thread_ilace new file mode 100644 index 0000000000..1320db98ad --- /dev/null +++ b/tests/ref/vsynth2/mpeg2thread_ilace @@ -0,0 +1,4 @@ +10b900e32809758857c596d56746e00e *./tests/data/vsynth2/mpeg2threadivlc.mpg +178801 ./tests/data/vsynth2/mpeg2threadivlc.mpg +8c6a7ed2eb73bd18fd2bb9829464100d *./tests/data/mpeg2thread_ilace.vsynth2.out.yuv +stddev: 4.72 PSNR: 34.65 MAXDIFF: 72 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg4_adap b/tests/ref/vsynth2/mpeg4_adap new file mode 100644 index 0000000000..b7a07dea5d --- /dev/null +++ b/tests/ref/vsynth2/mpeg4_adap @@ -0,0 +1,4 @@ +547e1849dcf910935ff6383ca49e5706 *./tests/data/vsynth2/mpeg4-adap.avi +198510 ./tests/data/vsynth2/mpeg4-adap.avi +4affb83f6adc94f31024b4f9e0168945 *./tests/data/mpeg4_adap.vsynth2.out.yuv +stddev: 3.75 PSNR: 36.65 MAXDIFF: 71 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg4_qpel b/tests/ref/vsynth2/mpeg4_qpel new file mode 100644 index 0000000000..d1f45153ba --- /dev/null +++ b/tests/ref/vsynth2/mpeg4_qpel @@ -0,0 +1,4 @@ +7680d2e7d34399dfdfb8a49cf1e10239 *./tests/data/vsynth2/mpeg4-Q.avi +163688 ./tests/data/vsynth2/mpeg4-Q.avi +26dc7c78955fa678fbf150e236eb5627 *./tests/data/mpeg4_qpel.vsynth2.out.yuv +stddev: 3.97 PSNR: 36.14 MAXDIFF: 54 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg4_qprd b/tests/ref/vsynth2/mpeg4_qprd new file mode 100644 index 0000000000..17eec96eff --- /dev/null +++ b/tests/ref/vsynth2/mpeg4_qprd @@ -0,0 +1,4 @@ +fd5ab0f55dbc959316e32923e86290df *./tests/data/vsynth2/mpeg4-qprd.avi +231458 ./tests/data/vsynth2/mpeg4-qprd.avi +de8a883865e2dff7a51f66da6c48df48 *./tests/data/mpeg4_qprd.vsynth2.out.yuv +stddev: 3.71 PSNR: 36.72 MAXDIFF: 61 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/mpeg4adv b/tests/ref/vsynth2/mpeg4adv index f8568c7828..b47cbf19fe 100644 --- a/tests/ref/vsynth2/mpeg4adv +++ b/tests/ref/vsynth2/mpeg4adv @@ -2,15 +2,3 @@ dee7be19486a76d96c88d18eefba8f86 *./tests/data/vsynth2/mpeg4-adv.avi 141546 ./tests/data/vsynth2/mpeg4-adv.avi 3f3a21e9db85a9c0f7022f557a5374c1 *./tests/data/mpeg4adv.vsynth2.out.yuv stddev: 4.94 PSNR: 34.25 MAXDIFF: 69 bytes: 7603200/ 7603200 -fd5ab0f55dbc959316e32923e86290df *./tests/data/vsynth2/mpeg4-qprd.avi -231458 ./tests/data/vsynth2/mpeg4-qprd.avi -de8a883865e2dff7a51f66da6c48df48 *./tests/data/mpeg4adv.vsynth2.out.yuv -stddev: 3.71 PSNR: 36.72 MAXDIFF: 61 bytes: 7603200/ 7603200 -547e1849dcf910935ff6383ca49e5706 *./tests/data/vsynth2/mpeg4-adap.avi -198510 ./tests/data/vsynth2/mpeg4-adap.avi -4affb83f6adc94f31024b4f9e0168945 *./tests/data/mpeg4adv.vsynth2.out.yuv -stddev: 3.75 PSNR: 36.65 MAXDIFF: 71 bytes: 7603200/ 7603200 -7680d2e7d34399dfdfb8a49cf1e10239 *./tests/data/vsynth2/mpeg4-Q.avi -163688 ./tests/data/vsynth2/mpeg4-Q.avi -26dc7c78955fa678fbf150e236eb5627 *./tests/data/mpeg4adv.vsynth2.out.yuv -stddev: 3.97 PSNR: 36.14 MAXDIFF: 54 bytes: 7603200/ 7603200 From 384bdaceeb9c82d5b64a6f73e5273298b38028e9 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sat, 19 Nov 2011 16:57:53 +0100 Subject: [PATCH 12/22] doxy: cleanup pixfmt.h Remove the dubious warning about the header being private and add some formatting --- libavutil/pixfmt.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 1861fdfb9a..39c608dde8 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -25,21 +25,21 @@ * @file * pixel format definitions * - * @warning This file has to be considered an internal but installed - * header, so it should not be directly included in your projects. */ #include "libavutil/avconfig.h" /** - * Pixel format. Notes: + * Pixel format. * + * @note * PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA * color is put together as: * (A << 24) | (R << 16) | (G << 8) | B * This is stored as BGRA on little-endian CPU architectures and ARGB on * big-endian CPUs. * + * @par * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized * image data is stored in AVFrame.data[0]. The palette is transported in * AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is @@ -49,13 +49,15 @@ * This is important as many custom PAL8 video codecs that were designed * to run on the IBM VGA graphics adapter use 6-bit palette components. * + * @par * For all the 8bit per pixel formats, an RGB32 palette is in data[1] like * for pal8. This palette is filled in automatically by the function * allocating the picture. * - * Note, make sure that all newly added big endian formats have pix_fmt&1==1 - * and that all newly added little endian formats have pix_fmt&1==0 - * this allows simpler detection of big vs little endian. + * @note + * make sure that all newly added big endian formats have pix_fmt&1==1 + * and that all newly added little endian formats have pix_fmt&1==0 + * this allows simpler detection of big vs little endian. */ enum PixelFormat { PIX_FMT_NONE= -1, From 757cd8d876b18c07e00b53fd4e5c01bedc106d2e Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sun, 20 Nov 2011 20:38:24 +0100 Subject: [PATCH 13/22] doxy: provide a start page and document libavutil Introduce a basic layout, the subpages are currently left empty. Split libavutil in multiple groups as example of the structure --- libavutil/adler32.h | 1 + libavutil/aes.h | 10 ++ libavutil/audioconvert.h | 24 ++++- libavutil/avstring.h | 21 ++-- libavutil/avutil.h | 200 ++++++++++++++++++++++++++++++++++++++- libavutil/base64.h | 11 +++ libavutil/dict.h | 11 ++- libavutil/error.h | 11 +++ libavutil/imgutils.h | 8 ++ libavutil/intmath.h | 8 ++ libavutil/lzo.h | 11 +++ libavutil/mathematics.h | 10 ++ libavutil/md5.h | 10 ++ libavutil/mem.h | 10 ++ libavutil/opt.h | 3 +- libavutil/random_seed.h | 8 ++ libavutil/rational.h | 9 ++ libavutil/sha.h | 10 ++ libavutil/tree.h | 17 +++- 19 files changed, 377 insertions(+), 16 deletions(-) diff --git a/libavutil/adler32.h b/libavutil/adler32.h index 913db2d0b6..a8ff6f9d41 100644 --- a/libavutil/adler32.h +++ b/libavutil/adler32.h @@ -25,6 +25,7 @@ #include "attributes.h" /** + * @ingroup lavu_crypto * Calculate the Adler32 checksum of a buffer. * * Passing the return value to a subsequent av_adler32_update() call diff --git a/libavutil/aes.h b/libavutil/aes.h index 6e5d320487..cf7b462092 100644 --- a/libavutil/aes.h +++ b/libavutil/aes.h @@ -23,6 +23,12 @@ #include +/** + * @defgroup lavu_aes AES + * @ingroup lavu_crypto + * @{ + */ + extern const int av_aes_size; struct AVAES; @@ -44,4 +50,8 @@ int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt); */ void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt); +/** + * @} + */ + #endif /* AVUTIL_AES_H */ diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h index e37a2e84c1..1c5cfa0a8e 100644 --- a/libavutil/audioconvert.h +++ b/libavutil/audioconvert.h @@ -29,7 +29,15 @@ * audio conversion routines */ -/* Audio channel masks */ +/** + * @addtogroup lavu_audio + * @{ + */ + +/** + * @defgroup channel_masks Audio channel masks + * @{ + */ #define AV_CH_FRONT_LEFT 0x00000001 #define AV_CH_FRONT_RIGHT 0x00000002 #define AV_CH_FRONT_CENTER 0x00000004 @@ -56,7 +64,11 @@ to be the native codec channel order. */ #define AV_CH_LAYOUT_NATIVE 0x8000000000000000LL -/* Audio channel convenience macros */ +/** + * @} + * @defgroup channel_mask_c Audio channel convenience macros + * @{ + * */ #define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER) #define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) #define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER) @@ -73,6 +85,10 @@ #define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) #define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) +/** + * @} + */ + /** * Return a channel layout id that matches name, 0 if no match. */ @@ -92,4 +108,8 @@ void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int6 */ int av_get_channel_layout_nb_channels(int64_t channel_layout); +/** + * @} + */ + #endif /* AVUTIL_AUDIOCONVERT_H */ diff --git a/libavutil/avstring.h b/libavutil/avstring.h index 6988f0e3e8..35b3d46c03 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -24,6 +24,11 @@ #include #include "attributes.h" +/** + * @addtogroup lavu_string + * @{ + */ + /** * Return non-zero if pfx is a prefix of str. If it is, *ptr is set to * the address of the first character in str after the prefix. @@ -72,7 +77,7 @@ char *av_stristr(const char *haystack, const char *needle); * @param size size of destination buffer * @return the length of src * - * WARNING: since the return value is the length of src, src absolutely + * @warning since the return value is the length of src, src absolutely * _must_ be a properly 0-terminated string, otherwise this will read beyond * the end of the buffer and possibly crash. */ @@ -90,9 +95,9 @@ size_t av_strlcpy(char *dst, const char *src, size_t size); * @param size size of destination buffer * @return the total length of src and dst * - * WARNING: since the return value use the length of src and dst, these absolutely - * _must_ be a properly 0-terminated strings, otherwise this will read beyond - * the end of the buffer and possibly crash. + * @warning since the return value use the length of src and dst, these + * absolutely _must_ be a properly 0-terminated strings, otherwise this + * will read beyond the end of the buffer and possibly crash. */ size_t av_strlcat(char *dst, const char *src, size_t size); @@ -153,14 +158,18 @@ static inline int av_tolower(int c) /* * Locale independent case-insensitive compare. - * Note: This means only ASCII-range characters are case-insensitive + * @note This means only ASCII-range characters are case-insensitive */ int av_strcasecmp(const char *a, const char *b); /** * Locale independent case-insensitive compare. - * Note: This means only ASCII-range characters are case-insensitive + * @note This means only ASCII-range characters are case-insensitive */ int av_strncasecmp(const char *a, const char *b, size_t n); +/** + * @} + */ + #endif /* AVUTIL_AVSTRING_H */ diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 436f79b82d..659a10f070 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -26,6 +26,95 @@ * external API header */ +/** + * @mainpage + * + * @section libav_intro Introduction + * + * This document describe the usage of the different libraries + * provided by Libav. + * + * @li @subpage libavcodec encoding/decoding library + * @li @subpage libavfilter graph based frame editing library + * @li @subpage libavformat I/O and muxing/demuxing library + * @li @ref lavu "libavutil" common utility library + * @li @subpage libpostproc post processing library + * @li @subpage libswscale color conversion and scaling library + * + */ + +/** + * @defgroup lavu Common utility functions + * + * @brief + * libavutil contains the code shared across all the other Libav + * libraries + * + * @note In order to use the functions provided by avutil you must include + * the specific header. + * + * @{ + * + * @defgroup lavu_crypto Crypto and Hashing + * + * @{ + * @} + * + * @defgroup lavu_math Maths + * @{ + * + * @} + * + * @defgroup lavu_string String Manipulation + * + * @{ + * + * @} + * + * @defgroup lavu_mem Memory Management + * + * @{ + * + * @} + * + * @defgroup lavu_data Data Structures + * @{ + * + * @} + * + * @defgroup lavu_audio Audio related + * + * @{ + * + * @} + * + * @defgroup lavu_error Error Codes + * + * @{ + * + * @} + * + * @defgroup lavu_misc Other + * + * @{ + * + * @defgroup lavu_internal Internal + * + * Not exported functions, for internal usage only + * + * @{ + * + * @} + */ + + +/** + * @defgroup preproc_misc Preprocessor String Macros + * + * String manipulation macros + * + * @{ + */ #define AV_STRINGIFY(s) AV_TOSTRING(s) #define AV_TOSTRING(s) #s @@ -35,10 +124,34 @@ #define AV_PRAGMA(s) _Pragma(#s) +/** + * @} + */ + +/** + * @defgroup version_utils Library Version Macros + * + * Useful to check and match library version in order to maintain + * backward compatibility. + * + * @{ + */ + #define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) #define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) +/** + * @} + * + * @defgroup lavu_ver Version and Build diagnostics + * + * Macros and function useful to check at compiletime and at runtime + * which version of libavutil is in use. + * + * @{ + */ + #define LIBAVUTIL_VERSION_MAJOR 51 #define LIBAVUTIL_VERSION_MINOR 16 #define LIBAVUTIL_VERSION_MICRO 0 @@ -54,8 +167,16 @@ #define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) /** + * @} + * + * @defgroup depr_guards Deprecation guards * Those FF_API_* defines are not part of public API. * They may change, break or disappear at any time. + * + * They are used mostly internally to mark code that will be removed + * on the next major version. + * + * @{ */ #ifndef FF_API_GET_BITS_PER_SAMPLE_FMT #define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52) @@ -70,6 +191,15 @@ #define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 52) #endif +/** + * @} + */ + +/** + * @addtogroup lavu_ver + * @{ + */ + /** * Return the LIBAVUTIL_VERSION_INT constant. */ @@ -85,16 +215,35 @@ const char *avutil_configuration(void); */ const char *avutil_license(void); +/** + * @} + */ + +/** + * @addtogroup lavu_media Media Type + * @brief Media Type + */ + enum AVMediaType { - AVMEDIA_TYPE_UNKNOWN = -1, + AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, - AVMEDIA_TYPE_DATA, + AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous AVMEDIA_TYPE_SUBTITLE, - AVMEDIA_TYPE_ATTACHMENT, + AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse AVMEDIA_TYPE_NB }; +/** + * @defgroup lavu_const Constants + * @{ + * + * @defgroup lavu_enc Encoding specific + * + * @note those definition should move to avcodec + * @{ + */ + #define FF_LAMBDA_SHIFT 7 #define FF_LAMBDA_SCALE (1< +/** + * @defgroup lavu_base64 Base64 + * @ingroup lavu_crypto + * @{ + */ + + /** * Decode a base64-encoded string. * @@ -51,4 +58,8 @@ char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size); */ #define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1) + /** + * @} + */ + #endif /* AVUTIL_BASE64_H */ diff --git a/libavutil/dict.h b/libavutil/dict.h index b0061c8475..6e28b61406 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -26,7 +26,11 @@ #define AVUTIL_DICT_H /** - * @defgroup dict_api Public Dictionary API + * @addtogroup lavu_dict AVDictionary + * @ingroup lavu_data + * + * @brief Simple key:value store + * * @{ * Dictionaries are used for storing key:value pairs. To create * an AVDictionary, simply pass an address of a NULL pointer to @@ -52,7 +56,6 @@ * av_dict_free(&d); * @endcode * - * @} */ #define AV_DICT_MATCH_CASE 1 @@ -111,4 +114,8 @@ void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags); */ void av_dict_free(AVDictionary **m); +/** + * @} + */ + #endif // AVUTIL_DICT_H diff --git a/libavutil/error.h b/libavutil/error.h index ba12d2bfae..8ed77342ef 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -27,6 +27,13 @@ #include #include "avutil.h" +/** + * @addtogroup lavu_error + * + * @{ + */ + + /* error handling */ #if EDOM > 0 #define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions. @@ -65,4 +72,8 @@ */ int av_strerror(int errnum, char *errbuf, size_t errbuf_size); +/** + * @} + */ + #endif /* AVUTIL_ERROR_H */ diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index 6017a70f71..3815a49ae4 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -22,6 +22,9 @@ /** * @file * misc image utilities + * + * @addtogroup lavu_picture + * @{ */ #include "avutil.h" @@ -127,4 +130,9 @@ int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *lo int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt); +/** + * @} + */ + + #endif /* AVUTIL_IMGUTILS_H */ diff --git a/libavutil/intmath.h b/libavutil/intmath.h index 3325975556..e6a2e102c4 100644 --- a/libavutil/intmath.h +++ b/libavutil/intmath.h @@ -25,6 +25,11 @@ #include "config.h" #include "attributes.h" +/** + * @addtogroup lavu_internal + * @{ + */ + extern const uint32_t ff_inverse[257]; #if ARCH_ARM @@ -76,4 +81,7 @@ static inline av_const unsigned int ff_sqrt(unsigned int a) return b - (a < b * b); } +/** + * @} + */ #endif /* AVUTIL_INTMATH_H */ diff --git a/libavutil/lzo.h b/libavutil/lzo.h index be86bba6bc..b4c71c0933 100644 --- a/libavutil/lzo.h +++ b/libavutil/lzo.h @@ -22,6 +22,13 @@ #ifndef AVUTIL_LZO_H #define AVUTIL_LZO_H +/** + * @defgroup lavu_lzo LZO + * @ingroup lavu_crypto + * + * @{ + */ + #include /** @name Error flags returned by av_lzo1x_decode @@ -63,4 +70,8 @@ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); */ void av_memcpy_backptr(uint8_t *dst, int back, int cnt); +/** + * @} + */ + #endif /* AVUTIL_LZO_H */ diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h index 35494bb391..0b072ebe63 100644 --- a/libavutil/mathematics.h +++ b/libavutil/mathematics.h @@ -57,6 +57,12 @@ #define INFINITY (1.0/0.0) #endif +/** + * @addtogroup lavu_math + * @{ + */ + + enum AVRounding { AV_ROUND_ZERO = 0, ///< Round toward zero. AV_ROUND_INF = 1, ///< Round away from zero. @@ -109,4 +115,8 @@ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); */ int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod); +/** + * @} + */ + #endif /* AVUTIL_MATHEMATICS_H */ diff --git a/libavutil/md5.h b/libavutil/md5.h index c178bbb4d5..1412ee2401 100644 --- a/libavutil/md5.h +++ b/libavutil/md5.h @@ -23,6 +23,12 @@ #include +/** + * @defgroup lavu_md5 MD5 + * @ingroup lavu_crypto + * @{ + */ + extern const int av_md5_size; struct AVMD5; @@ -32,5 +38,9 @@ void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len); +/** + * @} + */ + #endif /* AVUTIL_MD5_H */ diff --git a/libavutil/mem.h b/libavutil/mem.h index e14e8d038c..cd8490b2da 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -29,6 +29,12 @@ #include "attributes.h" #include "avutil.h" +/** + * @addtogroup lavu_mem + * @{ + */ + + #if defined(__ICC) && _ICC < 1200 || defined(__SUNPRO_C) #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v @@ -123,4 +129,8 @@ char *av_strdup(const char *s) av_malloc_attrib; */ void av_freep(void *ptr); +/** + * @} + */ + #endif /* AVUTIL_MEM_H */ diff --git a/libavutil/opt.h b/libavutil/opt.h index 6182326af2..19549408e2 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -34,6 +34,7 @@ /** * @defgroup avoptions AVOptions + * @ingroup lavu_data * @{ * AVOptions provide a generic system to declare options on arbitrary structs * ("objects"). An option can have a help text, a type and a range of possible @@ -212,7 +213,6 @@ * filled with option as a parameter. This allows to set some options * that cannot be set otherwise, since e.g. the input file format is not known * before the file is actually opened. - * @} */ enum AVOptionType{ @@ -584,6 +584,7 @@ int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val); int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val); /** + * @} * @} */ diff --git a/libavutil/random_seed.h b/libavutil/random_seed.h index 5bfeb8b835..b1fad13d07 100644 --- a/libavutil/random_seed.h +++ b/libavutil/random_seed.h @@ -22,6 +22,10 @@ #define AVUTIL_RANDOM_SEED_H #include +/** + * @addtogroup lavu_crypto + * @{ + */ /** * Get random data. @@ -33,4 +37,8 @@ */ uint32_t av_get_random_seed(void); +/** + * @} + */ + #endif /* AVUTIL_RANDOM_SEED_H */ diff --git a/libavutil/rational.h b/libavutil/rational.h index a4871148bd..0ec18ec969 100644 --- a/libavutil/rational.h +++ b/libavutil/rational.h @@ -32,6 +32,11 @@ #include #include "attributes.h" +/** + * @addtogroup lavu_math + * @{ + */ + /** * rational number numerator/denominator */ @@ -132,4 +137,8 @@ int av_nearer_q(AVRational q, AVRational q1, AVRational q2); */ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list); +/** + * @} + */ + #endif /* AVUTIL_RATIONAL_H */ diff --git a/libavutil/sha.h b/libavutil/sha.h index df261fa4b5..8350954c4b 100644 --- a/libavutil/sha.h +++ b/libavutil/sha.h @@ -23,6 +23,12 @@ #include +/** + * @defgroup lavu_sha SHA + * @ingroup lavu_crypto + * @{ + */ + extern const int av_sha_size; struct AVSHA; @@ -53,4 +59,8 @@ void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len) */ void av_sha_final(struct AVSHA* context, uint8_t *digest); +/** + * @} + */ + #endif /* AVUTIL_SHA_H */ diff --git a/libavutil/tree.h b/libavutil/tree.h index 9115e2fec1..59ea01dbdb 100644 --- a/libavutil/tree.h +++ b/libavutil/tree.h @@ -21,14 +21,24 @@ /** * @file * A tree container. - * Insertion, removal, finding equal, largest which is smaller than and - * smallest which is larger than, all have O(log n) worst case complexity. * @author Michael Niedermayer */ #ifndef AVUTIL_TREE_H #define AVUTIL_TREE_H +/** + * @addtogroup lavu_tree AVTree + * @ingroup lavu_data + * + * Low complexity tree container + * + * Insertion, removal, finding equal, largest which is smaller than and + * smallest which is larger than, all have O(log n) worst case complexity. + * @{ + */ + + struct AVTreeNode; extern const int av_tree_node_size; @@ -91,5 +101,8 @@ void av_tree_destroy(struct AVTreeNode *t); */ void av_tree_enumerate(struct AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem)); +/** + * @} + */ #endif /* AVUTIL_TREE_H */ From e97e5a2e0244c2daa2d696cb69ee96a0e77e1eb1 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sun, 20 Nov 2011 21:29:52 +0100 Subject: [PATCH 14/22] doxy: introduce an empty structure in libavcodec --- libavcodec/avcodec.h | 31 +++++++++++++++++++++++++++++++ libavutil/avutil.h | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 67bbdf89a2..dc794b0538 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -36,6 +36,37 @@ #include "libavutil/rational.h" #include "libavcodec/version.h" +/** + * @defgroup libavc Encoding/Decoding Library + * @{ + * + * @defgroup lavc_decoding Decoding + * @{ + * @} + * + * @defgroup lavc_encoding Encoding + * @{ + * @} + * + * @defgroup lavc_codec Codecs + * @{ + * @defgroup lavc_codec_native Native Codecs + * @{ + * @} + * @defgroup lavc_codec_wrappers External library wrappers + * @{ + * @} + * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge + * @{ + * @} + * @} + * @defgroup lavc_internal Internal + * @{ + * @} + * @} + * + */ + /** * Identify the syntax and semantics of the bitstream. diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 659a10f070..a1a9c38c8a 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -34,7 +34,7 @@ * This document describe the usage of the different libraries * provided by Libav. * - * @li @subpage libavcodec encoding/decoding library + * @li @ref libavc "libavcodec" encoding/decoding library * @li @subpage libavfilter graph based frame editing library * @li @subpage libavformat I/O and muxing/demuxing library * @li @ref lavu "libavutil" common utility library From e361b5089a5b782662eac92d4a76b12c6eaa11be Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 22 Nov 2011 17:11:28 +0100 Subject: [PATCH 15/22] doxy: structure libavformat groups --- libavformat/avformat.h | 34 ++++++++++++++++++++++++++++++++++ libavutil/avutil.h | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 33e820e4e1..5276af1c15 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -21,6 +21,40 @@ #ifndef AVFORMAT_AVFORMAT_H #define AVFORMAT_AVFORMAT_H +/** + * @defgroup libavf I/O and Muxing/Demuxing Library + * @{ + * + * @defgroup lavf_decoding Demuxing + * @{ + * @} + * + * @defgroup lavf_encoding Muxing + * @{ + * @} + * + * @defgroup lavf_proto I/O Read/Write + * @{ + * @} + * + * @defgroup lavf_codec Demuxers + * @{ + * @defgroup lavf_codec_native Native Demuxers + * @{ + * @} + * @defgroup lavf_codec_wrappers External library wrappers + * @{ + * @} + * @} + * @defgroup lavf_protos I/O Protocols + * @{ + * @} + * @defgroup lavf_internal Internal + * @{ + * @} + * @} + * + */ /** * Return the LIBAVFORMAT_VERSION_INT constant. diff --git a/libavutil/avutil.h b/libavutil/avutil.h index a1a9c38c8a..5381a41d73 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -36,7 +36,7 @@ * * @li @ref libavc "libavcodec" encoding/decoding library * @li @subpage libavfilter graph based frame editing library - * @li @subpage libavformat I/O and muxing/demuxing library + * @li @ref libavf "libavformat" I/O and muxing/demuxing library * @li @ref lavu "libavutil" common utility library * @li @subpage libpostproc post processing library * @li @subpage libswscale color conversion and scaling library From 85770d6e56472eefb690b3871ebf337e08537ce1 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 17 Jul 2011 11:19:35 +0100 Subject: [PATCH 16/22] Add libavutil/mathematics.h #includes for INFINITY This fixes build errors in some environments. Signed-off-by: Mans Rullgard --- cmdutils.c | 1 + libavcodec/aaccoder.c | 1 + libavcodec/nellymoserenc.c | 1 + 3 files changed, 3 insertions(+) diff --git a/cmdutils.c b/cmdutils.c index 51f617c40a..1c2bf4696b 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -35,6 +35,7 @@ #include "libswscale/swscale.h" #include "libpostproc/postprocess.h" #include "libavutil/avstring.h" +#include "libavutil/mathematics.h" #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavutil/eval.h" diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index b64bf9fa2d..f8a8f3d844 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -33,6 +33,7 @@ #include "libavutil/libm.h" // brought forward to work around cygwin header breakage #include +#include "libavutil/mathematics.h" #include "avcodec.h" #include "put_bits.h" #include "aac.h" diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c index 0f521db1e9..d3715ac740 100644 --- a/libavcodec/nellymoserenc.c +++ b/libavcodec/nellymoserenc.c @@ -35,6 +35,7 @@ * http://wiki.multimedia.cx/index.php?title=Nellymoser */ +#include "libavutil/mathematics.h" #include "nellymoser.h" #include "avcodec.h" #include "dsputil.h" From 9f8c190bb0f713832e10c5ba1723617acd6bf72c Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 21 Nov 2011 18:46:02 -0800 Subject: [PATCH 17/22] mov: Remove some redundant and obsolete comments. --- libavformat/mov.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ced60cbbb7..356a5e8ff4 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -44,21 +44,6 @@ /* * First version by Francois Revol revol@free.fr * Seek function by Gael Chardon gael.dev@4now.net - * - * Features and limitations: - * - reads most of the QT files I have (at least the structure), - * Sample QuickTime files with mp3 audio can be found at: http://www.3ivx.com/showcase.html - * - the code is quite ugly... maybe I won't do it recursive next time :-) - * - * Funny I didn't know about http://sourceforge.net/projects/qt-ffmpeg/ - * when coding this :) (it's a writer anyway) - * - * Reference documents: - * http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt - * Apple: - * http://developer.apple.com/documentation/QuickTime/QTFF/ - * http://developer.apple.com/documentation/QuickTime/QTFF/qtff.pdf - * QuickTime is a trademark of Apple (AFAIK :)) */ #include "qtpalette.h" @@ -67,13 +52,7 @@ #undef NDEBUG #include -/* XXX: it's the first time I make a recursive parser I think... sorry if it's ugly :P */ - /* those functions parse an atom */ -/* return code: - 0: continue to parse next atom - <0: error occurred, exit -*/ /* links atom IDs to parse functions */ typedef struct MOVParseTableEntry { uint32_t type; From 05d1e45d1f42cc90d1f2f36c546d0096cea126a8 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 22 Nov 2011 13:37:52 -0500 Subject: [PATCH 18/22] wma: initialize prev_block_len_bits, next_block_len_bits, and block_len_bits. The initial values are not checked against the number of block sizes. Initializing them to frame_len_bits will result in a block size index of 0 in these cases instead of something that might be out-of-range. Fixes Bug 81. --- libavcodec/wma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/wma.c b/libavcodec/wma.c index bed47ec35b..4cdffcd101 100644 --- a/libavcodec/wma.c +++ b/libavcodec/wma.c @@ -137,6 +137,9 @@ int ff_wma_init(AVCodecContext *avctx, int flags2) /* compute MDCT block size */ s->frame_len_bits = ff_wma_get_frame_len_bits(s->sample_rate, s->version, 0); + s->next_block_len_bits = s->frame_len_bits; + s->prev_block_len_bits = s->frame_len_bits; + s->block_len_bits = s->frame_len_bits; s->frame_len = 1 << s->frame_len_bits; if (s->use_variable_block_len) { From 395f2e70dd26524cb82d412cb938ded508df4d42 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 6 Nov 2011 20:43:13 -0500 Subject: [PATCH 19/22] dsputil: use movups instead of movdqu in ff_emu_edge_core_sse() This allows emulated_edge_mc_sse() and gmc_sse() to be used under AV_CPU_FLAG_SSE. --- libavcodec/x86/dsputil_mmx.c | 8 ++++---- libavcodec/x86/dsputil_yasm.asm | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index f0de05a763..104bd7595f 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2874,6 +2874,10 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) #if HAVE_YASM c->scalarproduct_float = ff_scalarproduct_float_sse; c->butterflies_float_interleave = ff_butterflies_float_interleave_sse; + + if (!high_bit_depth) + c->emulated_edge_mc = emulated_edge_mc_sse; + c->gmc = gmc_sse; #endif } if (HAVE_AMD3DNOW && (mm_flags & AV_CPU_FLAG_3DNOW)) @@ -2894,10 +2898,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->apply_window_int16 = ff_apply_window_int16_sse2; } } - - if (!high_bit_depth) - c->emulated_edge_mc = emulated_edge_mc_sse; - c->gmc= gmc_sse; #endif } if (mm_flags & AV_CPU_FLAG_SSSE3) { diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm index f2894cd501..8723a7e0b0 100644 --- a/libavcodec/x86/dsputil_yasm.asm +++ b/libavcodec/x86/dsputil_yasm.asm @@ -637,7 +637,7 @@ cglobal emu_edge_core_%1, 2, 7, 0 %ifnidn %3, mmx %rep %2/16 - movdqu xmm %+ %%sxidx, [r1+%%src_off] + movups xmm %+ %%sxidx, [r1+%%src_off] %assign %%src_off %%src_off+16 %assign %%sxidx %%sxidx+1 %endrep ; %2/16 @@ -686,7 +686,7 @@ cglobal emu_edge_core_%1, 2, 7, 0 %ifnidn %3, mmx %rep %2/16 - movdqu [r0+%%dst_off], xmm %+ %%dxidx + movups [r0+%%dst_off], xmm %+ %%dxidx %assign %%dst_off %%dst_off+16 %assign %%dxidx %%dxidx+1 %endrep ; %2/16 @@ -915,7 +915,7 @@ ALIGN 64 %define linesize r2m V_COPY_NPX %1, mm0, movq, 8, 0xFFFFFFF8 %else ; !mmx - V_COPY_NPX %1, xmm0, movdqu, 16, 0xFFFFFFF0 + V_COPY_NPX %1, xmm0, movups, 16, 0xFFFFFFF0 %ifdef ARCH_X86_64 %define linesize r2 V_COPY_NPX %1, rax , mov, 8 From 0e8fdd41c268a68a64447de037be2a279ce4afe2 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 6 Nov 2011 17:42:50 -0500 Subject: [PATCH 20/22] dsputil: use cpuflags in x86 emu_edge_core avoids passing around the extra argument among all the macros it uses --- libavcodec/x86/dsputil_yasm.asm | 91 +++++++++++++++++---------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm index 8723a7e0b0..4d2fb6a373 100644 --- a/libavcodec/x86/dsputil_yasm.asm +++ b/libavcodec/x86/dsputil_yasm.asm @@ -497,14 +497,14 @@ cglobal scalarproduct_float_sse, 3,3,2, v1, v2, offset ; ... and then the same for left/right extend also. See below for loop ; function implementations. Fast are fixed-width, slow is variable-width -%macro EMU_EDGE_FUNC 1 +%macro EMU_EDGE_FUNC 0 %ifdef ARCH_X86_64 %define w_reg r10 -cglobal emu_edge_core_%1, 6, 7, 1 +cglobal emu_edge_core, 6, 7, 1 mov r11, r5 ; save block_h %else %define w_reg r6 -cglobal emu_edge_core_%1, 2, 7, 0 +cglobal emu_edge_core, 2, 7, 0 mov r4, r4m ; end_y mov r5, r5m ; block_h %endif @@ -630,18 +630,18 @@ cglobal emu_edge_core_%1, 2, 7, 0 ; - if (%2 & 3 == 3) fills 2 bytes into r6, and 1 into ebx ; - else fills remaining bytes into ebx ; writing data out is in the same way -%macro READ_NUM_BYTES 3 +%macro READ_NUM_BYTES 2 %assign %%src_off 0 ; offset in source buffer %assign %%smidx 0 ; mmx register idx %assign %%sxidx 0 ; xmm register idx -%ifnidn %3, mmx +%if cpuflag(sse) %rep %2/16 movups xmm %+ %%sxidx, [r1+%%src_off] %assign %%src_off %%src_off+16 %assign %%sxidx %%sxidx+1 %endrep ; %2/16 -%endif ; !mmx +%endif %ifdef ARCH_X86_64 %if (%2-%%src_off) == 8 @@ -679,12 +679,12 @@ cglobal emu_edge_core_%1, 2, 7, 0 %endif ; (%2-%%src_off) == 1/2/3 %endmacro ; READ_NUM_BYTES -%macro WRITE_NUM_BYTES 3 +%macro WRITE_NUM_BYTES 2 %assign %%dst_off 0 ; offset in destination buffer %assign %%dmidx 0 ; mmx register idx %assign %%dxidx 0 ; xmm register idx -%ifnidn %3, mmx +%if cpuflag(sse) %rep %2/16 movups [r0+%%dst_off], xmm %+ %%dxidx %assign %%dst_off %%dst_off+16 @@ -734,7 +734,7 @@ cglobal emu_edge_core_%1, 2, 7, 0 ; those out into the destination buffer ; r0=buf,r1=src,r2=linesize,r3(64)/r3m(32)=start_x,r4=end_y,r5=block_h ; r6(eax/64)/r3(ebx/32)=val_reg -%macro VERTICAL_EXTEND 1 +%macro VERTICAL_EXTEND 0 %assign %%n 1 %rep 22 ALIGN 128 @@ -747,9 +747,9 @@ ALIGN 128 cmp dword r3m, 0 je .emuedge_copy_body_ %+ %%n %+ _loop %endif ; ARCH_X86_64/32 - READ_NUM_BYTES top, %%n, %1 ; read bytes + READ_NUM_BYTES top, %%n ; read bytes .emuedge_extend_top_ %+ %%n %+ _loop: ; do { - WRITE_NUM_BYTES top, %%n, %1 ; write bytes + WRITE_NUM_BYTES top, %%n ; write bytes add r0 , r2 ; dst += linesize %ifdef ARCH_X86_64 dec r3d @@ -760,8 +760,8 @@ ALIGN 128 ; copy body pixels .emuedge_copy_body_ %+ %%n %+ _loop: ; do { - READ_NUM_BYTES body, %%n, %1 ; read bytes - WRITE_NUM_BYTES body, %%n, %1 ; write bytes + READ_NUM_BYTES body, %%n ; read bytes + WRITE_NUM_BYTES body, %%n ; write bytes add r0 , r2 ; dst += linesize add r1 , r2 ; src += linesize dec r4d @@ -771,9 +771,9 @@ ALIGN 128 test r5 , r5 ; if (!block_h) jz .emuedge_v_extend_end_ %+ %%n ; goto end sub r1 , r2 ; src -= linesize - READ_NUM_BYTES bottom, %%n, %1 ; read bytes + READ_NUM_BYTES bottom, %%n ; read bytes .emuedge_extend_bottom_ %+ %%n %+ _loop: ; do { - WRITE_NUM_BYTES bottom, %%n, %1 ; write bytes + WRITE_NUM_BYTES bottom, %%n ; write bytes add r0 , r2 ; dst += linesize dec r5d jnz .emuedge_extend_bottom_ %+ %%n %+ _loop ; } while (--block_h) @@ -796,17 +796,17 @@ ALIGN 128 ; lowest two bytes of the register (so val*0x0101), and are splatted ; into each byte of mm0 as well if n_pixels >= 8 -%macro READ_V_PIXEL 3 +%macro READ_V_PIXEL 2 mov vall, %2 mov valh, vall %if %1 >= 8 movd mm0, vald -%ifidn %3, mmx +%if cpuflag(mmx2) + pshufw mm0, mm0, 0 +%else ; mmx punpcklwd mm0, mm0 punpckldq mm0, mm0 -%else ; !mmx - pshufw mm0, mm0, 0 -%endif ; mmx +%endif ; sse %endif ; %1 >= 8 %endmacro @@ -831,13 +831,13 @@ ALIGN 128 %endmacro ; r0=buf+block_h*linesize, r1=start_x, r2=linesize, r5=block_h, r6/r3=val -%macro LEFT_EXTEND 1 +%macro LEFT_EXTEND 0 %assign %%n 2 %rep 11 ALIGN 64 .emuedge_extend_left_ %+ %%n: ; do { sub r0, r2 ; dst -= linesize - READ_V_PIXEL %%n, [r0+r1], %1 ; read pixels + READ_V_PIXEL %%n, [r0+r1] ; read pixels WRITE_V_PIXEL %%n, r0 ; write pixels dec r5 jnz .emuedge_extend_left_ %+ %%n ; } while (--block_h) @@ -851,19 +851,19 @@ ALIGN 64 %endmacro ; LEFT_EXTEND ; r3/r0=buf+block_h*linesize, r2=linesize, r11/r5=block_h, r0/r6=end_x, r6/r3=val -%macro RIGHT_EXTEND 1 +%macro RIGHT_EXTEND 0 %assign %%n 2 %rep 11 ALIGN 64 .emuedge_extend_right_ %+ %%n: ; do { %ifdef ARCH_X86_64 sub r3, r2 ; dst -= linesize - READ_V_PIXEL %%n, [r3+w_reg-1], %1 ; read pixels + READ_V_PIXEL %%n, [r3+w_reg-1] ; read pixels WRITE_V_PIXEL %%n, r3+r4-%%n ; write pixels dec r11 %else ; ARCH_X86_32 sub r0, r2 ; dst -= linesize - READ_V_PIXEL %%n, [r0+w_reg-1], %1 ; read pixels + READ_V_PIXEL %%n, [r0+w_reg-1] ; read pixels WRITE_V_PIXEL %%n, r0+r4-%%n ; write pixels dec r5 %endif ; ARCH_X86_64/32 @@ -905,16 +905,16 @@ ALIGN 64 .%1_skip_%4_px: %endmacro -%macro V_COPY_ROW 3 +%macro V_COPY_ROW 2 %ifidn %1, bottom sub r1, linesize %endif .%1_copy_loop: xor cnt_reg, cnt_reg -%ifidn %3, mmx +%if notcpuflag(sse) %define linesize r2m V_COPY_NPX %1, mm0, movq, 8, 0xFFFFFFF8 -%else ; !mmx +%else ; sse V_COPY_NPX %1, xmm0, movups, 16, 0xFFFFFFF0 %ifdef ARCH_X86_64 %define linesize r2 @@ -923,7 +923,7 @@ ALIGN 64 %define linesize r2m V_COPY_NPX %1, mm0, movq, 8 %endif ; ARCH_X86_64/32 -%endif ; mmx +%endif ; sse V_COPY_NPX %1, vald, mov, 4 V_COPY_NPX %1, valw, mov, 2 V_COPY_NPX %1, vall, mov, 1 @@ -936,7 +936,7 @@ ALIGN 64 jnz .%1_copy_loop %endmacro -%macro SLOW_V_EXTEND 1 +%macro SLOW_V_EXTEND 0 .slow_v_extend_loop: ; r0=buf,r1=src,r2(64)/r2m(32)=linesize,r3(64)/r3m(32)=start_x,r4=end_y,r5=block_h ; r11(64)/r3(later-64)/r2(32)=cnt_reg,r6(64)/r3(32)=val_reg,r10(64)/r6(32)=w=end_x-start_x @@ -945,16 +945,16 @@ ALIGN 64 test r3, r3 %define cnt_reg r11 jz .do_body_copy ; if (!start_y) goto do_body_copy - V_COPY_ROW top, r3, %1 + V_COPY_ROW top, r3 %else cmp dword r3m, 0 %define cnt_reg r2 je .do_body_copy ; if (!start_y) goto do_body_copy - V_COPY_ROW top, dword r3m, %1 + V_COPY_ROW top, dword r3m %endif .do_body_copy: - V_COPY_ROW body, r4, %1 + V_COPY_ROW body, r4 %ifdef ARCH_X86_64 pop r11 ; restore old value of block_h @@ -966,7 +966,7 @@ ALIGN 64 %else jz .skip_bottom_extend %endif - V_COPY_ROW bottom, r5, %1 + V_COPY_ROW bottom, r5 %ifdef ARCH_X86_32 .skip_bottom_extend: mov r2, r2m @@ -974,12 +974,12 @@ ALIGN 64 jmp .v_extend_end %endmacro -%macro SLOW_LEFT_EXTEND 1 +%macro SLOW_LEFT_EXTEND 0 .slow_left_extend_loop: ; r0=buf+block_h*linesize,r2=linesize,r6(64)/r3(32)=val,r5=block_h,r4=cntr,r10/r6=start_x mov r4, 8 sub r0, linesize - READ_V_PIXEL 8, [r0+w_reg], %1 + READ_V_PIXEL 8, [r0+w_reg] .left_extend_8px_loop: movq [r0+r4-8], mm0 add r4, 8 @@ -1002,7 +1002,7 @@ ALIGN 64 jmp .right_extend %endmacro -%macro SLOW_RIGHT_EXTEND 1 +%macro SLOW_RIGHT_EXTEND 0 .slow_right_extend_loop: ; r3(64)/r0(32)=buf+block_h*linesize,r2=linesize,r4=block_w,r11(64)/r5(32)=block_h, ; r10(64)/r6(32)=end_x,r6/r3=val,r1=cntr @@ -1015,7 +1015,7 @@ ALIGN 64 %endif lea r1, [r4-8] sub buf_reg, linesize - READ_V_PIXEL 8, [buf_reg+w_reg-1], %1 + READ_V_PIXEL 8, [buf_reg+w_reg-1] .right_extend_8px_loop: movq [buf_reg+r1], mm0 sub r1, 8 @@ -1036,13 +1036,14 @@ ALIGN 64 %endmacro %macro emu_edge 1 -EMU_EDGE_FUNC %1 -VERTICAL_EXTEND %1 -LEFT_EXTEND %1 -RIGHT_EXTEND %1 -SLOW_V_EXTEND %1 -SLOW_LEFT_EXTEND %1 -SLOW_RIGHT_EXTEND %1 +INIT_XMM %1 +EMU_EDGE_FUNC +VERTICAL_EXTEND +LEFT_EXTEND +RIGHT_EXTEND +SLOW_V_EXTEND +SLOW_LEFT_EXTEND +SLOW_RIGHT_EXTEND %endmacro emu_edge sse From 105ab61c5f68d58731ccc592176aa9fc073b32b1 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Tue, 22 Nov 2011 10:38:37 -0800 Subject: [PATCH 21/22] avconv: Consistently use PIX_FMT_NONE. Use PIX_FMT_NONE instead of -1 when dealing with PixelFormat variables. --- avconv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avconv.c b/avconv.c index a87f852444..a03c9c1ba9 100644 --- a/avconv.c +++ b/avconv.c @@ -673,11 +673,11 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec) p= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE}; } } - for(; *p!=-1; p++){ + for (; *p != PIX_FMT_NONE; p++) { if(*p == st->codec->pix_fmt) break; } - if (*p == -1) { + if (*p == PIX_FMT_NONE) { if(st->codec->pix_fmt != PIX_FMT_NONE) av_log(NULL, AV_LOG_WARNING, "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n", From 963f6855356fa527a27b08b55e026f683a12cebc Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Tue, 22 Nov 2011 12:12:10 -0800 Subject: [PATCH 22/22] aacdec: Fix PS in ADTS. Fixes File1.aac and Bug 80. --- libavcodec/aacdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 203ecd3423..1015030b9a 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -2085,7 +2085,8 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) ac->m4ac.chan_config = hdr_info.chan_config; if (set_default_channel_config(ac->avctx, new_che_pos, hdr_info.chan_config)) return -7; - if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME)) + if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, + FFMAX(ac->output_configured, OC_TRIAL_FRAME))) return -7; } else if (ac->output_configured != OC_LOCKED) { ac->m4ac.chan_config = 0;