From d3f610c186b6e8430e4cf97667750e720f6983c8 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 1 Jun 2011 17:33:38 -0700 Subject: [PATCH 01/14] avidec: infer absolute vs relative index from first packet --- libavformat/avidec.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 7e509ce8ce..871da0bb40 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -836,7 +836,7 @@ static int get_stream_idx(int *d){ } } -static int avi_sync(AVFormatContext *s) +static int avi_sync(AVFormatContext *s, int exit_early) { AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; @@ -916,7 +916,9 @@ start_sync: if( (st->discard >= AVDISCARD_DEFAULT && size==0) /*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/ //FIXME needs a little reordering || st->discard >= AVDISCARD_ALL){ - ast->frame_offset += get_duration(ast, size); + if (!exit_early) { + ast->frame_offset += get_duration(ast, size); + } avio_skip(pb, size); goto start_sync; } @@ -936,6 +938,8 @@ start_sync: (d[2] == 'd' && d[3] == 'c') || (d[2] == 'w' && d[3] == 'b')*/) { + if (exit_early) + return 0; //av_log(s, AV_LOG_DEBUG, "OK\n"); if(d[2]*256+d[3] == ast->prefix) ast->prefix_count++; @@ -1117,7 +1121,7 @@ resync: return size; } - if ((err = avi_sync(s)) < 0) + if ((err = avi_sync(s, 0)) < 0) return err; goto resync; } @@ -1131,13 +1135,22 @@ static int avi_read_idx1(AVFormatContext *s, int size) int nb_index_entries, i; AVStream *st; AVIStream *ast; - unsigned int index, tag, flags, pos, len; + unsigned int index, tag, flags, pos, len, first_packet = 1; unsigned last_pos= -1; + int64_t idx1_pos, first_packet_pos = 0, data_offset = 0; nb_index_entries = size / 16; if (nb_index_entries <= 0) return -1; + idx1_pos = avio_tell(pb); + avio_seek(pb, avi->movi_list+4, SEEK_SET); + if (avi_sync(s, 1) == 0) { + first_packet_pos = avio_tell(pb) - 8; + } + avi->stream_index = -1; + avio_seek(pb, idx1_pos, SEEK_SET); + /* Read the entries and sort them in each stream component. */ for(i = 0; i < nb_index_entries; i++) { tag = avio_rl32(pb); @@ -1146,9 +1159,6 @@ static int avi_read_idx1(AVFormatContext *s, int size) len = avio_rl32(pb); av_dlog(s, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/", i, tag, flags, pos, len); - if(i==0 && pos > avi->movi_list) - avi->movi_list= 0; //FIXME better check - pos += avi->movi_list; index = ((tag & 0xff) - '0') * 10; index += ((tag >> 8) & 0xff) - '0'; @@ -1157,6 +1167,12 @@ static int avi_read_idx1(AVFormatContext *s, int size) st = s->streams[index]; ast = st->priv_data; + if(first_packet && first_packet_pos && len) { + data_offset = first_packet_pos - pos; + first_packet = 0; + } + pos += data_offset; + av_dlog(s, "%d cum_len=%"PRId64"\n", len, ast->cum_len); if(pb->eof_reached) From 5001d6ef4a2b70fe903b1d2e3e64c6ad7cc1cfa6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 1 Jul 2011 21:24:17 +0200 Subject: [PATCH 02/14] lavf: use the correct pointer in av_open_input_stream(). --- libavformat/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 776697b5bb..92debd5404 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -461,8 +461,9 @@ int av_open_input_stream(AVFormatContext **ic_ptr, } ic->pb = pb; - err = avformat_open_input(ic_ptr, filename, fmt, &opts); + err = avformat_open_input(&ic, filename, fmt, &opts); + *ic_ptr = ic; fail: av_dict_free(&opts); return err; From 4f731c4429e1fe66a5c92ff15feb63253a36d8fb Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 24 Jun 2011 07:58:16 +0200 Subject: [PATCH 03/14] lavf: restore old behavior for custom AVIOContex with an AVFMT_NOFILE format. av_open_input_stream used to allow this, even though it makes no sense. Make it just print a warning instead of failing, thus restoring compatibility. Note that avformat_open_input() will still reject this combination. Signed-off-by: Anton Khirnov --- libavformat/utils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 92debd5404..de26a1886e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -459,9 +459,14 @@ int av_open_input_stream(AVFormatContext **ic_ptr, err = AVERROR(ENOMEM); goto fail; } - ic->pb = pb; + if (pb && fmt && fmt->flags & AVFMT_NOFILE) + av_log(ic, AV_LOG_WARNING, "Custom AVIOContext makes no sense and " + "will be ignored with AVFMT_NOFILE format.\n"); + else + ic->pb = pb; err = avformat_open_input(&ic, filename, fmt, &opts); + ic->pb = ic->pb ? ic->pb : pb; // don't leak custom pb if it wasn't set above *ic_ptr = ic; fail: From 1a53a438dc04e74628b39f29d3ff81ae4aa086a0 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 1 Jul 2011 20:49:14 +0200 Subject: [PATCH 04/14] avformat: doxify the Metadata API convert the comment that documents the metadata API to use the doxygen markup --- libavformat/avformat.h | 73 ++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9abc9c51a4..05e80f1922 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -48,63 +48,68 @@ const char *avformat_license(void); struct AVFormatContext; -/* - * Public Metadata API. +/** + * @defgroup metadata_api Public Metadata API + * @{ * The metadata API allows libavformat to export metadata tags to a client * application using a sequence of key/value pairs. Like all strings in Libav, * metadata must be stored as UTF-8 encoded Unicode. Note that metadata * exported by demuxers isn't checked to be valid UTF-8 in most cases. * Important concepts to keep in mind: - * 1. Keys are unique; there can never be 2 tags with the same key. This is + * - Keys are unique; there can never be 2 tags with the same key. This is * also meant semantically, i.e., a demuxer should not knowingly produce * several keys that are literally different but semantically identical. * E.g., key=Author5, key=Author6. In this example, all authors must be * placed in the same tag. - * 2. Metadata is flat, not hierarchical; there are no subtags. If you + * - Metadata is flat, not hierarchical; there are no subtags. If you * want to store, e.g., the email address of the child of producer Alice * and actor Bob, that could have key=alice_and_bobs_childs_email_address. - * 3. Several modifiers can be applied to the tag name. This is done by + * - Several modifiers can be applied to the tag name. This is done by * appending a dash character ('-') and the modifier name in the order * they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng. - * a) language -- a tag whose value is localized for a particular language + * - language -- a tag whose value is localized for a particular language * is appended with the ISO 639-2/B 3-letter language code. * For example: Author-ger=Michael, Author-eng=Mike * The original/default language is in the unqualified "Author" tag. * A demuxer should set a default if it sets any translated tag. - * b) sorting -- a modified version of a tag that should be used for + * - sorting -- a modified version of a tag that should be used for * sorting will have '-sort' appended. E.g. artist="The Beatles", * artist-sort="Beatles, The". * - * 4. Demuxers attempt to export metadata in a generic format, however tags + * - Demuxers attempt to export metadata in a generic format, however tags * with no generic equivalents are left as they are stored in the container. * Follows a list of generic tag names: * - * album -- name of the set this work belongs to - * album_artist -- main creator of the set/album, if different from artist. - * e.g. "Various Artists" for compilation albums. - * artist -- main creator of the work - * comment -- any additional description of the file. - * composer -- who composed the work, if different from artist. - * copyright -- name of copyright holder. - * creation_time-- date when the file was created, preferably in ISO 8601. - * date -- date when the work was created, preferably in ISO 8601. - * disc -- number of a subset, e.g. disc in a multi-disc collection. - * encoder -- name/settings of the software/hardware that produced the file. - * encoded_by -- person/group who created the file. - * filename -- original name of the file. - * genre -- . - * language -- main language in which the work is performed, preferably - * in ISO 639-2 format. Multiple languages can be specified by - * separating them with commas. - * performer -- artist who performed the work, if different from artist. - * E.g for "Also sprach Zarathustra", artist would be "Richard - * Strauss" and performer "London Philharmonic Orchestra". - * publisher -- name of the label/publisher. - * service_name -- name of the service in broadcasting (channel name). - * service_provider -- name of the service provider in broadcasting. - * title -- name of the work. - * track -- number of this work in the set, can be in form current/total. - * variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of + @verbatim + album -- name of the set this work belongs to + album_artist -- main creator of the set/album, if different from artist. + e.g. "Various Artists" for compilation albums. + artist -- main creator of the work + comment -- any additional description of the file. + composer -- who composed the work, if different from artist. + copyright -- name of copyright holder. + creation_time-- date when the file was created, preferably in ISO 8601. + date -- date when the work was created, preferably in ISO 8601. + disc -- number of a subset, e.g. disc in a multi-disc collection. + encoder -- name/settings of the software/hardware that produced the file. + encoded_by -- person/group who created the file. + filename -- original name of the file. + genre -- . + language -- main language in which the work is performed, preferably + in ISO 639-2 format. Multiple languages can be specified by + separating them with commas. + performer -- artist who performed the work, if different from artist. + E.g for "Also sprach Zarathustra", artist would be "Richard + Strauss" and performer "London Philharmonic Orchestra". + publisher -- name of the label/publisher. + service_name -- name of the service in broadcasting (channel name). + service_provider -- name of the service provider in broadcasting. + title -- name of the work. + track -- number of this work in the set, can be in form current/total. + variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of + @endverbatim + * + * @} */ #if FF_API_OLD_METADATA2 From 7655cfb1b8d8a70e8cc4b1ca811bfc3f293768d8 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 1 Jul 2011 20:53:09 +0200 Subject: [PATCH 05/14] doxygen: be more permissive when searching for API examples --- Doxyfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doxyfile b/Doxyfile index bc9e7a1253..2502548aed 100644 --- a/Doxyfile +++ b/Doxyfile @@ -591,14 +591,14 @@ EXCLUDE_SYMBOLS = # directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = libavcodec/api-example.c libavformat/output-example.c +EXAMPLE_PATH = libavcodec/ libavformat/ # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = *-example.c # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude From 21a19b7912fe0622f3d1748ff102fcc7bc7a974a Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 1 Jul 2011 15:32:21 +0200 Subject: [PATCH 06/14] doxygen: Prefer member groups over grouping into modules Before this, almost all module groups have been used for grouping functions and fields in structures semantically. This causes them to not appear properly in the file documentation and needlessly clutters up the "Modules" index. Additionally, this commit streamlines some spelling and appearances. --- libavcodec/aac.h | 9 +-- libavcodec/ac3.h | 4 +- libavcodec/ac3dec.h | 30 ++++---- libavcodec/amrnbdec.c | 16 ++--- libavcodec/apedec.c | 2 +- libavcodec/ass.h | 3 +- libavcodec/avcodec.h | 4 +- libavcodec/h264.h | 2 +- libavcodec/qcelpdata.h | 4 +- libavcodec/rv34.c | 155 ++++++++++++++++++++-------------------- libavcodec/rv40data.h | 2 +- libavcodec/sbr.h | 8 +-- libavcodec/tableprint.h | 2 +- libavcodec/vc1.c | 2 +- libavcodec/vc1dec.c | 6 +- libavcodec/wmavoice.c | 22 +++--- libavformat/avio.h | 12 ++-- libavformat/rtmppkt.h | 2 +- libavutil/lzo.h | 2 +- 19 files changed, 143 insertions(+), 144 deletions(-) diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 76b6a7821b..4861ec0320 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -258,7 +258,7 @@ typedef struct { DynamicRangeControl che_drc; /** - * @defgroup elements Channel element related data. + * @name Channel element related data * @{ */ enum ChannelPosition che_pos[4][MAX_ELEM_ID]; /**< channel element channel mapping with the @@ -270,14 +270,15 @@ typedef struct { /** @} */ /** - * @defgroup temporary aligned temporary buffers (We do not want to have these on the stack.) + * @name temporary aligned temporary buffers + * (We do not want to have these on the stack.) * @{ */ DECLARE_ALIGNED(32, float, buf_mdct)[1024]; /** @} */ /** - * @defgroup tables Computed / set up during initialization. + * @name Computed / set up during initialization * @{ */ FFTContext mdct; @@ -289,7 +290,7 @@ typedef struct { /** @} */ /** - * @defgroup output Members used for output interleaving. + * @name Members used for output interleaving * @{ */ float *output_data[MAX_CHANNELS]; ///< Points to each element's 'ret' buffer (PCM output). diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h index c06f3d542d..9adad93db8 100644 --- a/libavcodec/ac3.h +++ b/libavcodec/ac3.h @@ -92,7 +92,7 @@ typedef struct AC3BitAllocParameters { * Coded AC-3 header values up to the lfeon element, plus derived values. */ typedef struct { - /** @defgroup coded Coded elements + /** @name Coded elements * @{ */ uint16_t sync_word; @@ -110,7 +110,7 @@ typedef struct { int num_blocks; ///< number of audio blocks /** @} */ - /** @defgroup derived Derived values + /** @name Derived values * @{ */ uint8_t sr_shift; diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index 590bee6b6d..aed87432f5 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -67,7 +67,7 @@ typedef struct { GetBitContext gbc; ///< bitstream reader uint8_t *input_buffer; ///< temp buffer to prevent overread -///@defgroup bsi bit stream information +///@name Bit stream information ///@{ int frame_type; ///< frame type (strmtyp) int substreamid; ///< substream identification @@ -85,7 +85,7 @@ typedef struct { int eac3; ///< indicates if current frame is E-AC-3 ///@} -///@defgroup audfrm frame syntax parameters +///@name Frame syntax parameters int snr_offset_strategy; ///< SNR offset strategy (snroffststr) int block_switch_syntax; ///< block switch syntax enabled (blkswe) int dither_flag_syntax; ///< dither flag syntax enabled (dithflage) @@ -95,7 +95,7 @@ typedef struct { int skip_syntax; ///< skip field syntax enabled (skipflde) ///@} -///@defgroup cpl standard coupling +///@name Standard coupling int cpl_in_use[AC3_MAX_BLOCKS]; ///< coupling in use (cplinu) int cpl_strategy_exists[AC3_MAX_BLOCKS];///< coupling strategy exists (cplstre) int channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl) @@ -108,7 +108,7 @@ typedef struct { int cpl_coords[AC3_MAX_CHANNELS][AC3_MAX_CPL_BANDS]; ///< coupling coordinates (cplco) ///@} -///@defgroup spx spectral extension +///@name Spectral extension ///@{ int spx_in_use; ///< spectral extension in use (spxinu) uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; ///< channel uses spectral extension (chinspx) @@ -124,12 +124,12 @@ typedef struct { float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact) ///@} -///@defgroup aht adaptive hybrid transform +///@name Adaptive hybrid transform int channel_uses_aht[AC3_MAX_CHANNELS]; ///< channel AHT in use (chahtinu) int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS]; ///< pre-IDCT mantissas ///@} -///@defgroup channel channel +///@name Channel int fbw_channels; ///< number of full-bandwidth channels int channels; ///< number of total channels int lfe_ch; ///< index of LFE channel @@ -139,27 +139,27 @@ typedef struct { int out_channels; ///< number of output channels ///@} -///@defgroup dynrng dynamic range +///@name Dynamic range float dynamic_range[2]; ///< dynamic range ///@} -///@defgroup bandwidth bandwidth +///@name Bandwidth int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant) int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant) ///@} -///@defgroup rematrixing rematrixing +///@name Rematrixing int num_rematrixing_bands; ///< number of rematrixing bands (nrematbnd) int rematrixing_flags[4]; ///< rematrixing flags (rematflg) ///@} -///@defgroup exponents exponents +///@name Exponents int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups (nexpgrp) int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< decoded exponents int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; ///< exponent strategies (expstr) ///@} -///@defgroup bitalloc bit allocation +///@name Bit allocation AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters int first_cpl_leak; ///< first coupling leak state (firstcplleak) int snr_offset[AC3_MAX_CHANNELS]; ///< signal-to-noise ratio offsets (snroffst) @@ -175,25 +175,25 @@ typedef struct { uint8_t dba_values[AC3_MAX_CHANNELS][8]; ///< delta values for each segment ///@} -///@defgroup dithering zero-mantissa dithering +///@name Zero-mantissa dithering int dither_flag[AC3_MAX_CHANNELS]; ///< dither flags (dithflg) AVLFG dith_state; ///< for dither generation ///@} -///@defgroup imdct IMDCT +///@name IMDCT int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags (blksw) FFTContext imdct_512; ///< for 512 sample IMDCT FFTContext imdct_256; ///< for 256 sample IMDCT ///@} -///@defgroup opt optimization +///@name Optimization DSPContext dsp; ///< for optimization AC3DSPContext ac3dsp; FmtConvertContext fmt_conv; ///< optimized conversion functions float mul_bias; ///< scaling for float_to_int16 conversion ///@} -///@defgroup arrays aligned arrays +///@name Aligned arrays DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< fixed-point transform coefficients DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients DECLARE_ALIGNED(32, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< delay - added to the next block diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index 4e24e26d68..1c90aadb12 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -204,7 +204,7 @@ static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf, } -/// @defgroup amr_lpc_decoding AMR pitch LPC coefficient decoding functions +/// @name AMR pitch LPC coefficient decoding functions /// @{ /** @@ -341,7 +341,7 @@ static void lsf2lsp_3(AMRContext *p) /// @} -/// @defgroup amr_pitch_vector_decoding AMR pitch vector decoding functions +/// @name AMR pitch vector decoding functions /// @{ /** @@ -403,7 +403,7 @@ static void decode_pitch_vector(AMRContext *p, /// @} -/// @defgroup amr_algebraic_code_book AMR algebraic code book (fixed) vector decoding functions +/// @name AMR algebraic code book (fixed) vector decoding functions /// @{ /** @@ -547,7 +547,7 @@ static void pitch_sharpening(AMRContext *p, int subframe, enum Mode mode, /// @} -/// @defgroup amr_gain_decoding AMR gain decoding functions +/// @name AMR gain decoding functions /// @{ /** @@ -633,7 +633,7 @@ static void decode_gains(AMRContext *p, const AMRNBSubframe *amr_subframe, /// @} -/// @defgroup amr_pre_processing AMR pre-processing functions +/// @name AMR preprocessing functions /// @{ /** @@ -751,7 +751,7 @@ static const float *anti_sparseness(AMRContext *p, AMRFixed *fixed_sparse, /// @} -/// @defgroup amr_synthesis AMR synthesis functions +/// @name AMR synthesis functions /// @{ /** @@ -812,7 +812,7 @@ static int synthesis(AMRContext *p, float *lpc, /// @} -/// @defgroup amr_update AMR update functions +/// @name AMR update functions /// @{ /** @@ -837,7 +837,7 @@ static void update_state(AMRContext *p) /// @} -/// @defgroup amr_postproc AMR Post processing functions +/// @name AMR Postprocessing functions /// @{ /** diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index d5a7efd94d..f92b37527e 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -217,7 +217,7 @@ static av_cold int ape_decode_close(AVCodecContext * avctx) } /** - * @defgroup rangecoder APE range decoder + * @name APE range decoding functions * @{ */ diff --git a/libavcodec/ass.h b/libavcodec/ass.h index d350cf3fc2..594b5f3ac6 100644 --- a/libavcodec/ass.h +++ b/libavcodec/ass.h @@ -25,8 +25,7 @@ #include "avcodec.h" /** - * Default values for ASS style. - * @defgroup ass_default + * @name Default values for ASS style * @{ */ #define ASS_DEFAULT_FONT "Arial" diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 1a45009968..45785e4d82 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2488,7 +2488,7 @@ typedef struct AVCodecContext { #if FF_API_FLAC_GLOBAL_OPTS /** - * @defgroup flac_opts FLAC options + * @name FLAC options * @deprecated Use FLAC encoder private options instead. * @{ */ @@ -2897,7 +2897,7 @@ typedef struct AVCodec { const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} /** - * @defgroup framethreading Frame-level threading support functions. + * @name Frame-level threading support functions * @{ */ /** diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 3abf895010..e3cc815565 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -507,7 +507,7 @@ typedef struct H264Context{ int cabac_init_idc; /** - * @defgroup multithreading Members for slice based multithreading + * @name Members for slice based multithreading * @{ */ struct H264Context *thread_context[MAX_THREADS]; diff --git a/libavcodec/qcelpdata.h b/libavcodec/qcelpdata.h index 457e856fa3..5822299348 100644 --- a/libavcodec/qcelpdata.h +++ b/libavcodec/qcelpdata.h @@ -38,14 +38,14 @@ * QCELP unpacked data frame */ typedef struct { -/// @defgroup qcelp_codebook_parameters QCELP excitation codebook parameters +/// @name QCELP excitation codebook parameters /// @{ uint8_t cbsign[16]; ///!< sign of the codebook gain for each codebook subframe uint8_t cbgain[16]; ///!< unsigned codebook gain for each codebook subframe uint8_t cindex[16]; ///!< codebook index for each codebook subframe /// @} -/// @defgroup qcelp_pitch_parameters QCELP pitch prediction parameters +/// @name QCELP pitch prediction parameters /// @{ uint8_t plag[4]; ///!< pitch lag for each pitch subframe uint8_t pfrac[4]; ///!< fractional pitch lag for each pitch subframe diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index b5d314cf0f..c5dcfdcba4 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -62,8 +62,10 @@ static const int rv34_mb_type_to_lavc[12] = { static RV34VLC intra_vlcs[NUM_INTRA_TABLES], inter_vlcs[NUM_INTER_TABLES]; +static int rv34_decode_mv(RV34DecContext *r, int block_type); + /** - * @defgroup vlc RV30/40 VLC generating functions + * @name RV30/40 VLC generating functions * @{ */ @@ -171,7 +173,7 @@ static av_cold void rv34_init_tables(void) /** - * @defgroup transform RV30/40 inverse transform functions + * @name RV30/40 inverse transform functions * @{ */ @@ -246,7 +248,7 @@ static void rv34_inv_transform_noround(DCTELEM *block){ /** - * @defgroup block RV30/40 4x4 block decoding functions + * @name RV30/40 4x4 block decoding functions * @{ */ @@ -393,7 +395,7 @@ static inline void rv34_dequant4x4_16x16(DCTELEM *block, int Qdc, int Q) /** - * @defgroup rv3040_bitstream RV30/40 bitstream parsing + * @name RV30/40 bitstream parsing * @{ */ @@ -432,10 +434,76 @@ static inline int rv34_decode_dquant(GetBitContext *gb, int quant) return get_bits(gb, 5); } +/** + * Decode macroblock header and return CBP in case of success, -1 otherwise. + */ +static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) +{ + MpegEncContext *s = &r->s; + GetBitContext *gb = &s->gb; + int mb_pos = s->mb_x + s->mb_y * s->mb_stride; + int i, t; + + if(!r->si.type){ + r->is16 = get_bits1(gb); + if(!r->is16 && !r->rv30){ + if(!get_bits1(gb)) + av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n"); + } + s->current_picture_ptr->mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA; + r->block_type = r->is16 ? RV34_MB_TYPE_INTRA16x16 : RV34_MB_TYPE_INTRA; + }else{ + r->block_type = r->decode_mb_info(r); + if(r->block_type == -1) + return -1; + s->current_picture_ptr->mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type]; + r->mb_type[mb_pos] = r->block_type; + if(r->block_type == RV34_MB_SKIP){ + if(s->pict_type == AV_PICTURE_TYPE_P) + r->mb_type[mb_pos] = RV34_MB_P_16x16; + if(s->pict_type == AV_PICTURE_TYPE_B) + r->mb_type[mb_pos] = RV34_MB_B_DIRECT; + } + r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->mb_type[mb_pos]); + rv34_decode_mv(r, r->block_type); + if(r->block_type == RV34_MB_SKIP){ + fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0])); + return 0; + } + r->chroma_vlc = 1; + r->luma_vlc = 0; + } + if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){ + if(r->is16){ + t = get_bits(gb, 2); + fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0])); + r->luma_vlc = 2; + }else{ + if(r->decode_intra_types(r, gb, intra_types) < 0) + return -1; + r->luma_vlc = 1; + } + r->chroma_vlc = 0; + r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); + }else{ + for(i = 0; i < 16; i++) + intra_types[(i & 3) + (i>>2) * r->intra_types_stride] = 0; + r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); + if(r->mb_type[mb_pos] == RV34_MB_P_MIX16x16){ + r->is16 = 1; + r->chroma_vlc = 1; + r->luma_vlc = 2; + r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); + } + } + + return rv34_decode_cbp(gb, r->cur_vlcs, r->is16); +} + /** @} */ //bitstream functions /** - * @defgroup mv motion vector related code (prediction, reconstruction, motion compensation) + * @name motion vector related code (prediction, reconstruction, motion compensation) * @{ */ @@ -885,7 +953,7 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type) /** @} */ // mv group /** - * @defgroup recons Macroblock reconstruction functions + * @name Macroblock reconstruction functions * @{ */ /** mapping of RV30/40 intra prediction types to standard H.264 types */ @@ -1027,79 +1095,6 @@ static void rv34_output_macroblock(RV34DecContext *r, int8_t *intra_types, int c } } -/** @} */ // recons group - -/** - * @addtogroup bitstream - * Decode macroblock header and return CBP in case of success, -1 otherwise. - */ -static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) -{ - MpegEncContext *s = &r->s; - GetBitContext *gb = &s->gb; - int mb_pos = s->mb_x + s->mb_y * s->mb_stride; - int i, t; - - if(!r->si.type){ - r->is16 = get_bits1(gb); - if(!r->is16 && !r->rv30){ - if(!get_bits1(gb)) - av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n"); - } - s->current_picture_ptr->mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA; - r->block_type = r->is16 ? RV34_MB_TYPE_INTRA16x16 : RV34_MB_TYPE_INTRA; - }else{ - r->block_type = r->decode_mb_info(r); - if(r->block_type == -1) - return -1; - s->current_picture_ptr->mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type]; - r->mb_type[mb_pos] = r->block_type; - if(r->block_type == RV34_MB_SKIP){ - if(s->pict_type == AV_PICTURE_TYPE_P) - r->mb_type[mb_pos] = RV34_MB_P_16x16; - if(s->pict_type == AV_PICTURE_TYPE_B) - r->mb_type[mb_pos] = RV34_MB_B_DIRECT; - } - r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->mb_type[mb_pos]); - rv34_decode_mv(r, r->block_type); - if(r->block_type == RV34_MB_SKIP){ - fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0])); - return 0; - } - r->chroma_vlc = 1; - r->luma_vlc = 0; - } - if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){ - if(r->is16){ - t = get_bits(gb, 2); - fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0])); - r->luma_vlc = 2; - }else{ - if(r->decode_intra_types(r, gb, intra_types) < 0) - return -1; - r->luma_vlc = 1; - } - r->chroma_vlc = 0; - r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); - }else{ - for(i = 0; i < 16; i++) - intra_types[(i & 3) + (i>>2) * r->intra_types_stride] = 0; - r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); - if(r->mb_type[mb_pos] == RV34_MB_P_MIX16x16){ - r->is16 = 1; - r->chroma_vlc = 1; - r->luma_vlc = 2; - r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); - } - } - - return rv34_decode_cbp(gb, r->cur_vlcs, r->is16); -} - -/** - * @addtogroup recons - * @{ - */ /** * mask for retrieving all bits in coded block pattern * corresponding to one 8x8 block @@ -1109,6 +1104,8 @@ static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) #define U_CBP_MASK 0x0F0000 #define V_CBP_MASK 0xF00000 +/** @} */ // recons group + static void rv34_apply_differences(RV34DecContext *r, int cbp) { diff --git a/libavcodec/rv40data.h b/libavcodec/rv40data.h index 4787075742..1b6e8c31b1 100644 --- a/libavcodec/rv40data.h +++ b/libavcodec/rv40data.h @@ -65,7 +65,7 @@ static const uint8_t rv40_luma_dc_quant[2][32] = { }; /** - * @defgroup loopfilter coefficients used by the RV40 loop filter + * @name Coefficients used by the RV40 loop filter * @{ */ /** diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h index cbf3e23e6b..5b0f334219 100644 --- a/libavcodec/sbr.h +++ b/libavcodec/sbr.h @@ -42,7 +42,7 @@ typedef struct { uint8_t bs_xover_band; /** - * @defgroup bs_header_extra_1 Variables associated with bs_header_extra_1 + * @name Variables associated with bs_header_extra_1 * @{ */ uint8_t bs_freq_scale; @@ -58,7 +58,7 @@ typedef struct { */ typedef struct { /** - * @defgroup aac_bitstream Main bitstream data variables + * @name Main bitstream data variables * @{ */ unsigned bs_frame_class; @@ -74,7 +74,7 @@ typedef struct { /** @} */ /** - * @defgroup state State variables + * @name State variables * @{ */ DECLARE_ALIGNED(16, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; @@ -116,7 +116,7 @@ typedef struct { SpectrumParameters spectrum_params; int bs_amp_res_header; /** - * @defgroup bs_header_extra_2 variables associated with bs_header_extra_2 + * @name Variables associated with bs_header_extra_2 * @{ */ unsigned bs_limiter_bands; diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index f6c72fe716..6f46a7cc8a 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -56,7 +56,7 @@ void write_##type##_2d_array(const void *arg, int len, int len2)\ } /** - * @defgroup printfuncs Predefined functions for printing tables + * @name Predefined functions for printing tables * * \{ */ diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 7b878c18d7..32869b97d1 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -40,7 +40,7 @@ /***********************************************************************/ /** - * @defgroup vc1bitplane VC-1 Bitplane decoding + * @name VC-1 Bitplane decoding * @see 8.7, p56 * @{ */ diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 186610ea95..8fca2da738 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -137,7 +137,7 @@ static int vc1_init_common(VC1Context *v) /***********************************************************************/ /** - * @defgroup vc1bitplane VC-1 Bitplane decoding + * @name VC-1 Bitplane decoding * @see 8.7, p56 * @{ */ @@ -774,7 +774,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v) /***********************************************************************/ /** - * @defgroup vc1block VC-1 Block-level functions + * @name VC-1 Block-level functions * @see 7.1.4, p91 and 8.1.1.7, p(1)04 * @{ */ @@ -1512,7 +1512,7 @@ static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, /** @} */ // Block group /** - * @defgroup vc1_std_mb VC1 Macroblock-level functions in Simple/Main Profiles + * @name VC1 Macroblock-level functions in Simple/Main Profiles * @see 7.1.4, p91 and 8.1.1.7, p(1)04 * @{ */ diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 4e69b83b32..eb3bcb0629 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -128,9 +128,7 @@ static const struct frame_type_desc { */ typedef struct { /** - * @defgroup struct_global Global values - * Global values, specified in the stream header / extradata or used - * all over. + * @name Global values specified in the stream header / extradata or used all over. * @{ */ GetBitContext gb; ///< packet bitreader. During decoder init, @@ -182,8 +180,9 @@ typedef struct { /** * @} - * @defgroup struct_packet Packet values - * Packet values, specified in the packet header or related to a packet. + * + * @name Packet values specified in the packet header or related to a packet. + * * A packet is considered to be a single unit of data provided to this * decoder by the demuxer. * @{ @@ -213,7 +212,8 @@ typedef struct { /** * @} - * @defgroup struct_frame Frame and superframe values + * + * @name Frame and superframe values * Superframe and frame data - these can change from frame to frame, * although some of them do in that case serve as a cache / history for * the next frame or superframe. @@ -256,7 +256,9 @@ typedef struct { float synth_history[MAX_LSPS]; ///< see #excitation_history /** * @} - * @defgroup post_filter Postfilter values + * + * @name Postfilter values + * * Variables used for postfilter implementation, mostly history for * smoothing and so on, and context variables for FFT/iFFT. * @{ @@ -432,7 +434,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) } /** - * @defgroup postfilter Postfilter functions + * @name Postfilter functions * Postfilter functions (gain control, wiener denoise filter, DC filter, * kalman smoothening, plus surrounding code to wrap it) * @{ @@ -825,7 +827,7 @@ static void dequant_lsps(double *lsps, int num, } /** - * @defgroup lsp_dequant LSP dequantization routines + * @name LSP dequantization routines * LSP dequantization routines, for 10/16LSPs and independent/residual coding. * @note we assume enough bits are available, caller should check. * lsp10i() consumes 24 bits; lsp10r() consumes an additional 24 bits; @@ -969,7 +971,7 @@ static void dequant_lsp16r(GetBitContext *gb, /** * @} - * @defgroup aw Pitch-adaptive window coding functions + * @name Pitch-adaptive window coding functions * The next few functions are for pitch-adaptive window coding. * @{ */ diff --git a/libavformat/avio.h b/libavformat/avio.h index bb2d9f85a6..be14e3c89d 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -145,7 +145,7 @@ typedef struct URLPollEntry { attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); /** - * @defgroup open_modes URL open modes + * @name URL open modes * The flags argument to url_open and cosins must be one of the following * constants, optionally ORed with other flags. * @{ @@ -176,7 +176,7 @@ extern URLInterruptCB *url_interrupt_cb; /** * @defgroup old_url_funcs Old url_* functions - * @deprecated use the buffered API based on AVIOContext instead + * The following functions are deprecated. Use the buffered API based on #AVIOContext instead. * @{ */ attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up, @@ -235,7 +235,7 @@ attribute_deprecated AVIOContext *av_alloc_put_byte( /** * @defgroup old_avio_funcs Old put_/get_*() functions - * @deprecated use the avio_ -prefixed functions instead. + * The following functions are deprecated. Use the "avio_"-prefixed functions instead. * @{ */ attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size); @@ -272,7 +272,7 @@ attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h, int stream_in /** * @defgroup old_url_f_funcs Old url_f* functions - * @deprecated use the avio_ -prefixed functions instead. + * The following functions are deprecated, use the "avio_"-prefixed functions instead. * @{ */ attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags); @@ -471,7 +471,7 @@ void avio_flush(AVIOContext *s); int avio_read(AVIOContext *s, unsigned char *buf, int size); /** - * @defgroup avio_read Functions for reading from AVIOContext. + * @name Functions for reading from AVIOContext * @{ * * @note return 0 if EOF, so you cannot use it if EOF handling is @@ -515,7 +515,7 @@ int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); /** - * @defgroup open_modes URL open modes + * @name URL open modes * The flags argument to avio_open must be one of the following * constants, optionally ORed with other flags. * @{ diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h index bb3475811e..8372484fbd 100644 --- a/libavformat/rtmppkt.h +++ b/libavformat/rtmppkt.h @@ -138,7 +138,7 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *p, void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p); /** - * @defgroup amffuncs functions used to work with AMF format (which is also used in .flv) + * @name Functions used to work with the AMF format (which is also used in .flv) * @see amf_* funcs in libavformat/flvdec.c * @{ */ diff --git a/libavutil/lzo.h b/libavutil/lzo.h index 41ee6b1d67..be86bba6bc 100644 --- a/libavutil/lzo.h +++ b/libavutil/lzo.h @@ -24,7 +24,7 @@ #include -/** @defgroup errflags Error flags returned by av_lzo1x_decode +/** @name Error flags returned by av_lzo1x_decode * \{ */ //! end of the input buffer reached before decoding finished #define AV_LZO_INPUT_DEPLETED 1 From 12489443dec228d60fa3dc56695f6ddae08beb37 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 1 Jul 2011 20:50:33 +0200 Subject: [PATCH 07/14] libavformat: Add an example how to use the metadata API Also include it into the doxygen documentation --- libavformat/Makefile | 2 +- libavformat/avformat.h | 2 ++ libavformat/metadata-example.c | 56 ++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 libavformat/metadata-example.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 3d22c6f265..a20db26b03 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -333,7 +333,7 @@ OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o # libavdevice dependencies OBJS-$(CONFIG_JACK_INDEV) += timefilter.o -EXAMPLES = output +EXAMPLES = metadata output TESTPROGS = timefilter include $(SRC_PATH)/subdir.mak diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 05e80f1922..8561a50c01 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -109,6 +109,8 @@ struct AVFormatContext; variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of @endverbatim * + * Look in the examples section for an application example how to use the Metadata API. + * * @} */ diff --git a/libavformat/metadata-example.c b/libavformat/metadata-example.c new file mode 100644 index 0000000000..7bf77e7378 --- /dev/null +++ b/libavformat/metadata-example.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011 Reinhard Tartler + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * @file + * @example libavformat/metadata-example.c + * Shows how the metadata API can be used in application programs. + */ + +#include + +#include +#include + +int main (int argc, char **argv) +{ + AVFormatContext *fmt_ctx = NULL; + AVDictionaryEntry *tag = NULL; + int ret; + + if (argc != 2) { + printf("usage: %s \n" + "example program to demonstrate the use of the libavformat metadata API.\n" + "\n", argv[0]); + return 1; + } + + av_register_all(); + if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL))) + return ret; + + while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) + printf("%s=%s\n", tag->key, tag->value); + + avformat_free_context(fmt_ctx); + return 0; +} From 30b05520c8b1d1574d7b62dee59776b50d231590 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 1 Jul 2011 16:35:37 +0100 Subject: [PATCH 08/14] put_bits: always use intreadwrite.h macros This fixes invalid unaligned stores in some ARM configurations. Signed-off-by: Mans Rullgard --- libavcodec/put_bits.h | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index 3849e6d339..b91e0f8f5a 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -70,8 +70,7 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_s s->buf_end = s->buf + buffer_size; #ifdef ALT_BITSTREAM_WRITER s->index=0; - ((uint32_t*)(s->buf))[0]=0; -// memset(buffer, 0, buffer_size); + AV_ZERO32(s->buf); #else s->buf_ptr = s->buf; s->bit_left=32; @@ -164,12 +163,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) #ifdef BITSTREAM_WRITER_LE bit_buf |= value << (32 - bit_left); if (n >= bit_left) { -#if !HAVE_FAST_UNALIGNED - if (3 & (intptr_t) s->buf_ptr) { - AV_WL32(s->buf_ptr, bit_buf); - } else -#endif - *(uint32_t *)s->buf_ptr = av_le2ne32(bit_buf); + AV_WL32(s->buf_ptr, bit_buf); s->buf_ptr+=4; bit_buf = (bit_left==32)?0:value >> bit_left; bit_left+=32; @@ -182,12 +176,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) } else { bit_buf<<=bit_left; bit_buf |= value >> (n - bit_left); -#if !HAVE_FAST_UNALIGNED - if (3 & (intptr_t) s->buf_ptr) { - AV_WB32(s->buf_ptr, bit_buf); - } else -#endif - *(uint32_t *)s->buf_ptr = av_be2ne32(bit_buf); + AV_WB32(s->buf_ptr, bit_buf); //printf("bitbuf = %08x\n", bit_buf); s->buf_ptr+=4; bit_left+=32 - n; From 0d5c349ac45a22da4944f5e7447d98c154590d24 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 2 Jul 2011 11:50:24 +0100 Subject: [PATCH 09/14] put_bits: remove ALT_BITSTREAM_WRITER The code for this variant does not compile. Signed-off-by: Mans Rullgard --- libavcodec/bitstream.c | 4 -- libavcodec/mpegvideo_enc.c | 2 - libavcodec/put_bits.h | 102 +------------------------------------ 3 files changed, 1 insertion(+), 107 deletions(-) diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 17b1c69c84..70717883c1 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -43,11 +43,7 @@ const uint8_t ff_log2_run[41]={ void align_put_bits(PutBitContext *s) { -#ifdef ALT_BITSTREAM_WRITER - put_bits(s,( - s->index) & 7,0); -#else put_bits(s,s->bit_left & 7,0); -#endif } void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index f3885626c1..cd13a5cd2b 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2170,9 +2170,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ int d= 100 / s->avctx->error_rate; if(r % d == 0){ current_packet_size=0; -#ifndef ALT_BITSTREAM_WRITER s->pb.buf_ptr= s->ptr_lastgob; -#endif assert(put_bits_ptr(&s->pb) == s->ptr_lastgob); } } diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index b91e0f8f5a..c10dd818f0 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -36,19 +36,10 @@ #include "mathops.h" #include "config.h" -//#define ALT_BITSTREAM_WRITER -//#define ALIGNED_BITSTREAM_WRITER - -/* buf and buf_end must be present and used by every alternative writer. */ typedef struct PutBitContext { -#ifdef ALT_BITSTREAM_WRITER - uint8_t *buf, *buf_end; - int index; -#else uint32_t bit_buf; int bit_left; uint8_t *buf, *buf_ptr, *buf_end; -#endif int size_in_bits; } PutBitContext; @@ -68,14 +59,9 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_s s->size_in_bits= 8*buffer_size; s->buf = buffer; s->buf_end = s->buf + buffer_size; -#ifdef ALT_BITSTREAM_WRITER - s->index=0; - AV_ZERO32(s->buf); -#else s->buf_ptr = s->buf; s->bit_left=32; s->bit_buf=0; -#endif } /** @@ -83,11 +69,7 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_s */ static inline int put_bits_count(PutBitContext *s) { -#ifdef ALT_BITSTREAM_WRITER - return s->index; -#else return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left; -#endif } /** @@ -95,9 +77,6 @@ static inline int put_bits_count(PutBitContext *s) */ static inline void flush_put_bits(PutBitContext *s) { -#ifdef ALT_BITSTREAM_WRITER - align_put_bits(s); -#else #ifndef BITSTREAM_WRITER_LE s->bit_buf<<= s->bit_left; #endif @@ -114,10 +93,9 @@ static inline void flush_put_bits(PutBitContext *s) } s->bit_left=32; s->bit_buf=0; -#endif } -#if defined(ALT_BITSTREAM_WRITER) || defined(BITSTREAM_WRITER_LE) +#ifdef BITSTREAM_WRITER_LE #define align_put_bits align_put_bits_unsupported_here #define ff_put_string ff_put_string_unsupported_here #define ff_copy_bits ff_copy_bits_unsupported_here @@ -147,7 +125,6 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); * Use put_bits32 to write 32 bits. */ static inline void put_bits(PutBitContext *s, int n, unsigned int value) -#ifndef ALT_BITSTREAM_WRITER { unsigned int bit_buf; int bit_left; @@ -187,70 +164,6 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) s->bit_buf = bit_buf; s->bit_left = bit_left; } -#else /* ALT_BITSTREAM_WRITER defined */ -{ -# ifdef ALIGNED_BITSTREAM_WRITER -# if ARCH_X86 - __asm__ volatile( - "movl %0, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "shrdl %%cl, %1, %%eax \n\t" - "shrl %%cl, %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "andl $0xFFFFFFFC, %%ecx \n\t" - "bswapl %1 \n\t" - "orl %1, (%2, %%ecx) \n\t" - "bswapl %%eax \n\t" - "addl %3, %0 \n\t" - "movl %%eax, 4(%2, %%ecx) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n)) - : "%eax", "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5); - - value<<= 32-n; - - ptr[0] |= av_be2ne32(value>>(index&31)); - ptr[1] = av_be2ne32(value<<(32-(index&31))); -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# else //ALIGNED_BITSTREAM_WRITER -# if ARCH_X86 - __asm__ volatile( - "movl $7, %%ecx \n\t" - "andl %0, %%ecx \n\t" - "addl %3, %%ecx \n\t" - "negl %%ecx \n\t" - "shll %%cl, %1 \n\t" - "bswapl %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "orl %1, (%%ecx, %2) \n\t" - "addl %3, %0 \n\t" - "movl $0, 4(%%ecx, %2) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value) - : "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3)); - - ptr[0] |= av_be2ne32(value<<(32-n-(index&7) )); - ptr[1] = 0; -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# endif //!ALIGNED_BITSTREAM_WRITER -} -#endif static inline void put_sbits(PutBitContext *pb, int n, int32_t value) { @@ -281,11 +194,7 @@ static void av_unused put_bits32(PutBitContext *s, uint32_t value) */ static inline uint8_t* put_bits_ptr(PutBitContext *s) { -#ifdef ALT_BITSTREAM_WRITER - return s->buf + (s->index>>3); -#else return s->buf_ptr; -#endif } /** @@ -295,13 +204,8 @@ static inline uint8_t* put_bits_ptr(PutBitContext *s) static inline void skip_put_bytes(PutBitContext *s, int n) { assert((put_bits_count(s)&7)==0); -#ifdef ALT_BITSTREAM_WRITER - FIXME may need some cleaning of the buffer - s->index += n<<3; -#else assert(s->bit_left==32); s->buf_ptr += n; -#endif } /** @@ -311,13 +215,9 @@ static inline void skip_put_bytes(PutBitContext *s, int n) */ static inline void skip_put_bits(PutBitContext *s, int n) { -#ifdef ALT_BITSTREAM_WRITER - s->index += n; -#else s->bit_left -= n; s->buf_ptr-= 4*(s->bit_left>>5); s->bit_left &= 31; -#endif } /** From f6d6783a4df127d2ad1cf755ac4f363decbd7fbb Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 13:22:18 +0200 Subject: [PATCH 10/14] ffmpeg: use av_get_bytes_per_sample() in place of av_get_bits_per_sample_fmt() av_get_bits_per_sample_fmt() was deprecated. Signed-off-by: Ronald S. Bultje --- ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index 9f2d5b98b4..b9309aed43 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1801,7 +1801,7 @@ static int output_packet(AVInputStream *ist, int ist_index, ret = 0; /* encode any samples remaining in fifo */ if (fifo_bytes > 0) { - int osize = av_get_bits_per_sample_fmt(enc->sample_fmt) >> 3; + int osize = av_get_bytes_per_sample(enc->sample_fmt); int fs_tmp = enc->frame_size; av_fifo_generic_read(ost->fifo, audio_buf, fifo_bytes, NULL); From ccfa626db863b6019fd4c316d19d8f7018543bed Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 13:22:35 +0200 Subject: [PATCH 11/14] suggest to use av_get_bytes_per_sample() in av_get_bits_per_sample_format() doxy The previously suggested replacement - av_get_bits_per_sample_fmt() - was also deprecated. Signed-off-by: Ronald S. Bultje --- libavcodec/avcodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 45785e4d82..fbd70395c4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3847,7 +3847,7 @@ int av_get_bits_per_sample(enum CodecID codec_id); #if FF_API_OLD_SAMPLE_FMT /** - * @deprecated Use av_get_bits_per_sample_fmt() instead. + * @deprecated Use av_get_bytes_per_sample() instead. */ attribute_deprecated int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt); From 8f440223f6cb2b557ea6e34ca4079fbe415ecb9d Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 26 Jun 2011 15:52:01 -0700 Subject: [PATCH 12/14] swscale: disable full_chroma_int when converting to non-24/32bpp RGB. This functionality is only implemented for RGB24/32 and causes crashes otherwise. --- libswscale/utils.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libswscale/utils.c b/libswscale/utils.c index eea32a130a..9f0bb7a8b9 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -845,6 +845,19 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat); // reuse chroma for 2 pixels RGB/BGR unless user wants full chroma interpolation + if (flags & SWS_FULL_CHR_H_INT && + dstFormat != PIX_FMT_RGBA && + dstFormat != PIX_FMT_ARGB && + dstFormat != PIX_FMT_BGRA && + dstFormat != PIX_FMT_ABGR && + dstFormat != PIX_FMT_RGB24 && + dstFormat != PIX_FMT_BGR24) { + av_log(c, AV_LOG_ERROR, + "full chroma interpolation for destination format '%s' not yet implemented\n", + sws_format_name(dstFormat)); + flags &= ~SWS_FULL_CHR_H_INT; + c->flags = flags; + } if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1; // drop some chroma lines if the user wants it From 8aa63f0b31544a63e107c67c519d6ccd11c94810 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 2 Jul 2011 17:21:02 +0100 Subject: [PATCH 13/14] ARM: NEON optimised vector_clip_int32() Signed-off-by: Mans Rullgard --- libavcodec/arm/dsputil_init_neon.c | 3 +++ libavcodec/arm/dsputil_neon.S | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libavcodec/arm/dsputil_init_neon.c b/libavcodec/arm/dsputil_init_neon.c index 3bc053c864..3f58dea9cd 100644 --- a/libavcodec/arm/dsputil_init_neon.c +++ b/libavcodec/arm/dsputil_init_neon.c @@ -160,6 +160,8 @@ void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1, void ff_vector_clipf_neon(float *dst, const float *src, float min, float max, int len); +void ff_vector_clip_int32_neon(int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); void ff_vorbis_inverse_coupling_neon(float *mag, float *ang, int blocksize); @@ -316,6 +318,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) c->vector_fmul_reverse = ff_vector_fmul_reverse_neon; c->vector_fmul_add = ff_vector_fmul_add_neon; c->vector_clipf = ff_vector_clipf_neon; + c->vector_clip_int32 = ff_vector_clip_int32_neon; c->vector_fmul_sv_scalar[0] = ff_vector_fmul_sv_scalar_2_neon; c->vector_fmul_sv_scalar[1] = ff_vector_fmul_sv_scalar_4_neon; diff --git a/libavcodec/arm/dsputil_neon.S b/libavcodec/arm/dsputil_neon.S index 5e3bf27f67..3b9b542a68 100644 --- a/libavcodec/arm/dsputil_neon.S +++ b/libavcodec/arm/dsputil_neon.S @@ -815,3 +815,19 @@ function ff_apply_window_int16_neon, export=1 pop {r4,pc} endfunc + +function ff_vector_clip_int32_neon, export=1 + vdup.32 q0, r2 + vdup.32 q1, r3 + ldr r2, [sp] +1: + vld1.32 {q2-q3}, [r1,:128]! + vmin.s32 q2, q2, q1 + vmin.s32 q3, q3, q1 + vmax.s32 q2, q2, q0 + vmax.s32 q3, q3, q0 + vst1.32 {q2-q3}, [r0,:128]! + subs r2, r2, #8 + bgt 1b + bx lr +endfunc From 5dd045ebc11933dca4d6af06e6b1e62be56802f7 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 2 Jul 2011 18:24:13 +0100 Subject: [PATCH 14/14] ARM: ac3: update ff_ac3_extract_exponents_neon per 8b7b2d6 Signed-off-by: Mans Rullgard --- libavcodec/arm/ac3dsp_neon.S | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libavcodec/arm/ac3dsp_neon.S b/libavcodec/arm/ac3dsp_neon.S index fdf1deabc9..e97197c27a 100644 --- a/libavcodec/arm/ac3dsp_neon.S +++ b/libavcodec/arm/ac3dsp_neon.S @@ -95,19 +95,14 @@ function ff_float_to_fixed24_neon, export=1 endfunc function ff_ac3_extract_exponents_neon, export=1 - vmov.i32 q14, #24 vmov.i32 q15, #8 1: - vld1.32 {q0}, [r1,:128] + vld1.32 {q0}, [r1,:128]! vabs.s32 q1, q0 vclz.i32 q3, q1 vsub.i32 q3, q3, q15 - vcge.s32 q2, q3, q14 - vbit q3, q14, q2 - vbic q0, q0, q2 vmovn.i32 d6, q3 vmovn.i16 d6, q3 - vst1.32 {q0}, [r1,:128]! vst1.32 {d6[0]}, [r0,:32]! subs r2, r2, #4 bgt 1b