From da9cea77e314dad2fbc615a76085a0c330741f92 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 5 Oct 2011 14:12:42 +0200 Subject: [PATCH 01/12] Fix a bunch of common typos. --- avconv.c | 2 +- avserver.c | 2 +- cmdutils.h | 6 +++--- doc/avconv.texi | 2 +- doc/avserver.texi | 2 +- doc/avtools-common-opts.texi | 2 +- doc/developer.texi | 4 ++-- doc/eval.texi | 4 ++-- doc/filters.texi | 18 +++++++++--------- doc/general.texi | 2 +- doc/protocols.texi | 6 +++--- doc/soc.txt | 2 +- ffmpeg.c | 2 +- libavcodec/avcodec.h | 4 ++-- libavcodec/bitstream.c | 2 +- libavcodec/dsputil.h | 4 ++-- libavcodec/eatgv.c | 4 ++-- libavcodec/error_resilience.c | 2 +- libavcodec/g722enc.c | 2 +- libavcodec/h264.c | 6 +++--- libavcodec/jfdctint_template.c | 2 +- libavcodec/lpc.h | 2 +- libavcodec/mjpegdec.c | 6 +++--- libavcodec/mpegvideo.h | 2 +- libavcodec/proresdec.c | 2 +- libavcodec/tscc.c | 2 +- libavcodec/vaapi_mpeg4.c | 2 +- libavcodec/vc1dec.c | 6 +++--- libavcodec/wmaprodec.c | 2 +- libavcodec/wmavoice.c | 4 ++-- libavcodec/x86/vc1dsp_yasm.asm | 2 +- libavdevice/jack_audio.c | 2 +- libavdevice/timefilter.h | 2 +- libavformat/avformat.h | 7 ++++--- libavformat/flvenc.c | 4 ++-- libavformat/id3v2.c | 2 +- libavformat/img2.c | 2 +- libavformat/iv8.c | 2 +- libavformat/mms.h | 2 +- libavformat/movenc.c | 2 +- libavformat/mpegts.c | 8 ++++---- libavformat/mpegtsenc.c | 2 +- libavformat/mxfenc.c | 2 +- libavformat/rdt.c | 2 +- libavformat/rtp.h | 2 +- libavformat/udp.c | 2 +- libavformat/utils.c | 4 ++-- libavutil/eval.h | 2 +- libpostproc/postprocess.c | 2 +- libpostproc/postprocess_internal.h | 2 +- tools/patcheck | 2 +- 51 files changed, 83 insertions(+), 82 deletions(-) diff --git a/avconv.c b/avconv.c index 0bc5aa0c3b..f3e80d3a86 100644 --- a/avconv.c +++ b/avconv.c @@ -3682,7 +3682,7 @@ static void opt_output_file(void *optctx, const char *filename) } if (!(oc->oformat->flags & AVFMT_NOFILE)) { - /* test if it already exists to avoid loosing precious files */ + /* test if it already exists to avoid losing precious files */ assert_file_overwrite(filename); /* open the file */ diff --git a/avserver.c b/avserver.c index ec5f2bea6b..e4d353b559 100644 --- a/avserver.c +++ b/avserver.c @@ -475,7 +475,7 @@ static void start_children(FFStream *feed) slash++; strcpy(slash, "avconv"); - http_log("Launch commandline: "); + http_log("Launch command line: "); http_log("%s ", pathname); for (i = 1; feed->child_argv[i] && feed->child_argv[i][0]; i++) http_log("%s ", feed->child_argv[i]); diff --git a/cmdutils.h b/cmdutils.h index fc438c7977..db75d53562 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -83,7 +83,7 @@ int opt_timelimit(const char *opt, const char *arg); * parsed or the corresponding value is invalid. * * @param context the context of the value to be set (e.g. the - * corresponding commandline option name) + * corresponding command line option name) * @param numstr the string to be parsed * @param type the type (OPT_INT64 or OPT_FLOAT) as which the * string should be parsed @@ -98,7 +98,7 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do * the string cannot be correctly parsed. * * @param context the context of the value to be set (e.g. the - * corresponding commandline option name) + * corresponding command line option name) * @param timestr the string to be parsed * @param is_duration a flag which tells how to interpret timestr, if * not zero timestr is interpreted as a duration, otherwise as a @@ -181,7 +181,7 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options); /** - * Find the '-loglevel' option in the commandline args and apply it. + * Find the '-loglevel' option in the command line args and apply it. */ void parse_loglevel(int argc, char **argv, const OptionDef *options); diff --git a/doc/avconv.texi b/doc/avconv.texi index 9946aaa61c..84e0c1c4ef 100644 --- a/doc/avconv.texi +++ b/doc/avconv.texi @@ -29,7 +29,7 @@ rates and resize video on the fly with a high quality polyphase filter. avconv reads from an arbitrary number of input "files" (which can be regular files, pipes, network streams, grabbing devices, etc.), specified by the @code{-i} option, and writes to an arbitrary number of output "files", which are -specified by a plain output filename. Anything found on the commandline which +specified by a plain output filename. Anything found on the command line which cannot be interpreted as an option is considered to be an output filename. Each input or output file can in principle contain any number of streams of diff --git a/doc/avserver.texi b/doc/avserver.texi index 351ee0da19..c023814e08 100644 --- a/doc/avserver.texi +++ b/doc/avserver.texi @@ -150,7 +150,7 @@ that only captures in stereo and also requires that one channel be flipped. If you are one of these people, then export 'AUDIO_FLIP_LEFT=1' before starting avconv. -@subsection The audio and video loose sync after a while. +@subsection The audio and video lose sync after a while. Yes, they do. diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi index 8892e9e431..372a6f2dc1 100644 --- a/doc/avtools-common-opts.texi +++ b/doc/avtools-common-opts.texi @@ -9,7 +9,7 @@ example 'KB', 'MiB', 'G' and 'B' as postfix. Options which do not take arguments are boolean options, and set the corresponding value to true. They can be set to false by prefixing with "no" the option name, for example using "-nofoo" in the -commandline will set to false the boolean option with name "foo". +command line will set to false the boolean option with name "foo". @section Stream specifiers Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers diff --git a/doc/developer.texi b/doc/developer.texi index dd31e3725b..e484520413 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -49,7 +49,7 @@ mailing list. The code is written in K&R C style. That means the following: @itemize @bullet @item -The control statements are formatted by putting space betwen the statement +The control statements are formatted by putting space between the statement and parenthesis in the following way: @example for (i = 0; i < filter->input_count; i++) @{ @@ -79,7 +79,7 @@ if (!pic || !picref) goto fail; @end example @item -Do not put spaces immediately inside parenthesis. @samp{if (ret)} is +Do not put spaces immediately inside parentheses. @samp{if (ret)} is a valid style; @samp{if ( ret )} is not. @end itemize diff --git a/doc/eval.texi b/doc/eval.texi index 7d8106b89e..7f8f3653b3 100644 --- a/doc/eval.texi +++ b/doc/eval.texi @@ -1,7 +1,7 @@ @chapter Expression Evaluation @c man begin EXPRESSION EVALUATION -When evaluating an arithemetic expression, Libav uses an internal +When evaluating an arithmetic expression, Libav uses an internal formula evaluator, implemented through the @file{libavutil/eval.h} interface. @@ -53,7 +53,7 @@ returns the value stored in the internal variable. @item ld(var) Allow to load the value of the internal variable with number -@var{var}, which was previosly stored with st(@var{var}, @var{expr}). +@var{var}, which was previously stored with st(@var{var}, @var{expr}). The function returns the loaded value. @item while(cond, expr) diff --git a/doc/filters.texi b/doc/filters.texi index 101bec6d88..e022b46531 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -200,7 +200,7 @@ input plane. They are expressions, and can contain the following constants: @table @option @item w, h -the input width and heigth in pixels +the input width and height in pixels @item cw, ch the input chroma image width and height in pixels @@ -888,7 +888,7 @@ the corresponding mathematical approximated values for e (euler number), pi (greek PI), PHI (golden ratio) @item w, h -the input width and heigth +the input width and height @item val input value for the pixel component @@ -992,7 +992,7 @@ The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}. filter. If not specified the default values are assumed. Refer to the official libopencv documentation for more precise -informations: +information: @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html} Follows the list of supported libopencv filters. @@ -1008,7 +1008,7 @@ It accepts the parameters: @var{struct_el}:@var{nb_iterations}. @var{struct_el} represents a structuring element, and has the syntax: @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape} -@var{cols} and @var{rows} represent the number of colums and rows of +@var{cols} and @var{rows} represent the number of columns and rows of the structuring element, @var{anchor_x} and @var{anchor_y} the anchor point, and @var{shape} the shape for the structuring element, and can be one of the values "rect", "cross", "ellipse", "custom". @@ -1184,7 +1184,7 @@ value for @var{width} or @var{height} is 0, the corresponding input size is used for the output. The @var{width} expression can reference the value set by the -@var{height} expression, and viceversa. +@var{height} expression, and vice versa. The default value of @var{width} and @var{height} is 0. @@ -1194,7 +1194,7 @@ Specify the offsets where to place the input image in the padded area with respect to the top/left border of the output image. The @var{x} expression can reference the value set by the @var{y} -expression, and viceversa. +expression, and vice versa. The default value of @var{x} and @var{y} is 0. @@ -1608,7 +1608,7 @@ seconds @item pos position of the frame in the input stream, -1 if this information in -unavailable and/or meanigless (for example in case of synthetic video) +unavailable and/or meaningless (for example in case of synthetic video) @item fmt pixel format name @@ -1825,7 +1825,7 @@ through the interface defined in @file{libavfilter/vsrc_buffer.h}. It accepts the following parameters: @var{width}:@var{height}:@var{pix_fmt_string}:@var{timebase_num}:@var{timebase_den}:@var{sample_aspect_ratio_num}:@var{sample_aspect_ratio.den} -All the parameters need to be explicitely defined. +All the parameters need to be explicitly defined. Follows the list of the accepted parameters. @@ -2017,7 +2017,7 @@ separated by ":". The description of the accepted options follows. @item size, s Specify the size of the sourced video, it may be a string of the form -@var{width}x@var{heigth}, or the name of a size abbreviation. The +@var{width}x@var{height}, or the name of a size abbreviation. The default value is "320x240". @item rate, r diff --git a/doc/general.texi b/doc/general.texi index b4838f5ae9..bbeea641d2 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -485,7 +485,7 @@ following image formats are supported: @item id RoQ video @tab X @tab X @tab Used in Quake III, Jedi Knight 2, other computer games. @item IFF ILBM @tab @tab X - @tab IFF interlaved bitmap + @tab IFF interleaved bitmap @item IFF ByteRun1 @tab @tab X @tab IFF run length encoded bitmap @item Intel H.263 @tab @tab X diff --git a/doc/protocols.texi b/doc/protocols.texi index 225fda85c9..f5bb5324be 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -155,8 +155,8 @@ be seekable, so they will fail with the pipe output protocol. Real-Time Messaging Protocol. -The Real-Time Messaging Protocol (RTMP) is used for streaming multime‐ -dia content across a TCP/IP network. +The Real-Time Messaging Protocol (RTMP) is used for streaming multimedia +content across a TCP/IP network. The required syntax is: @example @@ -195,7 +195,7 @@ Real-Time Messaging Protocol and its variants supported through librtmp. Requires the presence of the librtmp headers and library during -configuration. You need to explicitely configure the build with +configuration. You need to explicitly configure the build with "--enable-librtmp". If enabled this will replace the native RTMP protocol. diff --git a/doc/soc.txt b/doc/soc.txt index e45bd6ce3b..89728b5201 100644 --- a/doc/soc.txt +++ b/doc/soc.txt @@ -18,7 +18,7 @@ essential that changes to their codebase are publicly visible, clean and easy reviewable that again leads us to: * use of a revision control system like git * separation of cosmetic from non-cosmetic changes (this is almost entirely - ignored by mentors and students in soc 2006 which might lead to a suprise + ignored by mentors and students in soc 2006 which might lead to a surprise when the code will be reviewed at the end before a possible inclusion in Libav, individual changes were generally not reviewable due to cosmetics). * frequent commits, so that comments can be provided early diff --git a/ffmpeg.c b/ffmpeg.c index c731cec53b..0ec3b241ca 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3797,7 +3797,7 @@ static void opt_output_file(void *optctx, const char *filename) } if (!(oc->oformat->flags & AVFMT_NOFILE)) { - /* test if it already exists to avoid loosing precious files */ + /* test if it already exists to avoid losing precious files */ if (!file_overwrite && (strchr(filename, ':') == NULL || filename[1] == ':' || diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 669afe80ba..ae5ce6e314 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1274,7 +1274,7 @@ typedef struct AVCodecContext { * Some codecs need additional format info. It is stored here. * If any muxer uses this then ALL demuxers/parsers AND encoders for the * specific codec MUST set it correctly otherwise stream copy breaks. - * In general use of this field by muxers is not recommanded. + * In general use of this field by muxers is not recommended. * - encoding: Set by libavcodec. * - decoding: Set by libavcodec. (FIXME: Is this OK?) */ @@ -3444,7 +3444,7 @@ typedef struct ReSampleContext ReSampleContext; * @param linear if 1 then the used FIR filter will be linearly interpolated between the 2 closest, if 0 the closest will be used * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate - * @return allocated ReSampleContext, NULL if error occured + * @return allocated ReSampleContext, NULL if error occurred */ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, int output_rate, int input_rate, diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 68ea3e0bda..14e392f34d 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -103,7 +103,7 @@ static int alloc_table(VLC *vlc, int size, int use_static) vlc->table_size += size; if (vlc->table_size > vlc->table_allocated) { if(use_static) - abort(); //cant do anything, init_vlc() is used with too little memory + abort(); // cannot do anything, init_vlc() is used with too little memory vlc->table_allocated += (1 << vlc->bits); vlc->table = av_realloc(vlc->table, sizeof(VLC_TYPE) * 2 * vlc->table_allocated); diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 98b7b1eeaa..300160986c 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -498,8 +498,8 @@ typedef struct DSPContext { * with the zigzag/alternate scan
* an example to avoid confusion: * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...) - * - (x -> referece dct -> reference idct -> x) - * - (x -> referece dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x) + * - (x -> reference dct -> reference idct -> x) + * - (x -> reference dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x) * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...) */ uint8_t idct_permutation[64]; diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index 917308f571..597d0db8da 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -155,7 +155,7 @@ static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *b vector_bits = AV_RL16(&buf[6]); buf += 12; - /* allocate codebook buffers as neccessary */ + /* allocate codebook buffers as necessary */ if (num_mvs > s->num_mvs) { s->mv_codebook = av_realloc(s->mv_codebook, num_mvs*2*sizeof(int)); s->num_mvs = num_mvs; @@ -286,7 +286,7 @@ static int tgv_decode_frame(AVCodecContext *avctx, s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; s->frame.linesize[0] = s->width; - /* allocate additional 12 bytes to accomodate av_memcpy_backptr() OUTBUF_PADDED optimisation */ + /* allocate additional 12 bytes to accommodate av_memcpy_backptr() OUTBUF_PADDED optimisation */ s->frame.data[0] = av_malloc(s->width*s->height + 12); if (!s->frame.data[0]) return AVERROR(ENOMEM); diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index 23ac904c6c..a2e911b951 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -790,7 +790,7 @@ void ff_er_frame_end(MpegEncContext *s){ if(!s->error_recognition || s->error_count==0 || s->avctx->lowres || s->avctx->hwaccel || s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU || - s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled + s->picture_structure != PICT_FRAME || // we do not support ER of field pictures yet, though it should not crash if enabled s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return; if (s->current_picture.f.motion_val[0] == NULL) { diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c index f8db49aba8..1eed784a72 100644 --- a/libavcodec/g722enc.c +++ b/libavcodec/g722enc.c @@ -153,7 +153,7 @@ static int g722_encode_trellis(AVCodecContext *avctx, for (j = 0; j < frontier && nodes[0][j]; j++) { /* Only k >> 2 affects the future adaptive state, therefore testing - * small steps that don't change k >> 2 is useless, the orignal + * small steps that don't change k >> 2 is useless, the original * value from encode_low is better than them. Since we step k * in steps of 4, make sure range is a multiple of 4, so that * we don't miss the original value from encode_low. */ diff --git a/libavcodec/h264.c b/libavcodec/h264.c index acd7179cc0..285aae81e5 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2893,7 +2893,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ * FIXME: avoiding a memcpy would be nice, but ref handling makes many assumptions * about there being no actual duplicates. * FIXME: this doesn't copy padding for out-of-frame motion vectors. Given we're - * concealing a lost frame, this probably isn't noticable by comparison, but it should + * concealing a lost frame, this probably isn't noticeable by comparison, but it should * be fixed. */ if (h->short_ref_count) { if (prev) { @@ -3316,7 +3316,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon /** * - * @return non zero if the loop filter can be skiped + * @return non zero if the loop filter can be skipped */ static int fill_filter_caches(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; @@ -3839,7 +3839,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ av_log(h->s.avctx, AV_LOG_ERROR, "Invalid mix of idr and non-idr slices"); return -1; } - idr(h); //FIXME ensure we don't loose some frames if there is reordering + idr(h); // FIXME ensure we don't lose some frames if there is reordering case NAL_SLICE: init_get_bits(&hx->s.gb, ptr, bit_length); hx->intra_gb_ptr= diff --git a/libavcodec/jfdctint_template.c b/libavcodec/jfdctint_template.c index 02b6f09381..5175390710 100644 --- a/libavcodec/jfdctint_template.c +++ b/libavcodec/jfdctint_template.c @@ -340,7 +340,7 @@ FUNC(ff_jpeg_fdct_islow)(DCTELEM *data) /* * The secret of DCT2-4-8 is really simple -- you do the usual 1-DCT - * on the rows and then, instead of doing even and odd, part on the colums + * on the rows and then, instead of doing even and odd, part on the columns * you do even part two times. */ GLOBAL(void) diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h index 8cc2362e5b..2a944b6f48 100644 --- a/libavcodec/lpc.h +++ b/libavcodec/lpc.h @@ -67,7 +67,7 @@ typedef struct LPCContext { * Perform autocorrelation on input samples with delay of 0 to lag. * @param data input samples. * constraints: no alignment needed, but must have have at - * least lag*sizeof(double) valid bytes preceeding it, and + * least lag*sizeof(double) valid bytes preceding it, and * size must be at least (len+1)*sizeof(double) if data is * 16-byte aligned or (len+2)*sizeof(double) if data is * unaligned. diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 0a1236c225..17e87ed65b 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1109,9 +1109,9 @@ static int mjpeg_decode_app(MJpegDecodeContext *s) av_log(s->avctx, AV_LOG_DEBUG, "APPx %8X\n", id); } - /* buggy AVID, it puts EOI only at every 10th frame */ - /* also this fourcc is used by non-avid files too, it holds some - informations, but it's always present in AVID creates files */ + /* Buggy AVID, it puts EOI only at every 10th frame. */ + /* Also, this fourcc is used by non-avid files too, it holds some + information, but it's always present in AVID-created files. */ if (id == AV_RL32("AVI1")) { /* structure: diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 46ad5d8306..01df491907 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -127,7 +127,7 @@ typedef struct Picture{ int ref_poc[2][2][16]; ///< h264 POCs of the frames used as reference (FIXME need per slice) int ref_count[2][2]; ///< number of entries in ref_poc (FIXME need per slice) int mbaff; ///< h264 1 -> MBAFF frame 0-> not MBAFF - int field_picture; ///< whether or not the picture was encoded in seperate fields + int field_picture; ///< whether or not the picture was encoded in separate fields int mb_var_sum; ///< sum of MB variance for current frame int mc_mb_var_sum; ///< motion compensated MB variance for current frame diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c index b4c794564b..46434df263 100644 --- a/libavcodec/proresdec.c +++ b/libavcodec/proresdec.c @@ -559,7 +559,7 @@ static int decode_slice(AVCodecContext *avctx, ProresThreadData *td) sf = sf > 128 ? (sf - 96) << 2 : sf; /* scale quantization matrixes according with slice's scale factor */ - /* TODO: this can be SIMD-optimized alot */ + /* TODO: this can be SIMD-optimized a lot */ if (ctx->qmat_changed || sf != ctx->prev_slice_sf) { ctx->prev_slice_sf = sf; for (i = 0; i < 64; i++) { diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index df4b09b07c..90d203dd77 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -155,7 +155,7 @@ static av_cold int decode_init(AVCodecContext *avctx) return -1; } c->bpp = avctx->bits_per_coded_sample; - // buffer size for RLE 'best' case when 2-byte code preceeds each pixel and there may be padding after it too + // buffer size for RLE 'best' case when 2-byte code precedes each pixel and there may be padding after it too c->decomp_size = (((avctx->width * c->bpp + 7) >> 3) + 3 * avctx->width + 2) * avctx->height + 2; /* Allocate decompression buffer */ diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index 915632844e..41d54c6116 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -98,7 +98,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture); /* Fill in VAIQMatrixBufferMPEG4 */ - /* Only the first inverse quantisation method uses the weighthing matrices */ + /* Only the first inverse quantisation method uses the weighting matrices */ if (pic_param->vol_fields.bits.quant_type) { iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferMPEG4)); if (!iq_matrix) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 7c9e906505..0340dc202d 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3536,7 +3536,7 @@ static void vc1_apply_p_loop_filter(VC1Context *v) vc1_apply_p_v_loop_filter(v, i); } - /* V always preceedes H, therefore we run H one MB before V; + /* V always precedes H, therefore we run H one MB before V; * at the end of a row, we catch up to complete the row */ if (s->mb_x) { for (i = 0; i < 6; i++) { @@ -3573,7 +3573,7 @@ static int vc1_decode_p_mb(VC1Context *v) int skipped, fourmv; int block_cbp = 0, pat, block_tt = 0, block_intra = 0; - mquant = v->pq; /* Loosy initialization */ + mquant = v->pq; /* lossy initialization */ if (v->mv_type_is_raw) fourmv = get_bits1(gb); @@ -4141,7 +4141,7 @@ static void vc1_decode_b_mb(VC1Context *v) int dmv_x[2], dmv_y[2]; int bmvtype = BMV_TYPE_BACKWARD; - mquant = v->pq; /* Loosy initialization */ + mquant = v->pq; /* lossy initialization */ s->mb_intra = 0; if (v->dmb_is_raw) diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index c46a983602..b947eb800f 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -1425,7 +1425,7 @@ static int remaining_bits(WMAProDecodeCtx *s, GetBitContext *gb) *@param s codec context *@param gb bitstream reader context *@param len length of the partial frame - *@param append decides wether to reset the buffer or not + *@param append decides whether to reset the buffer or not */ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, int append) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 6f3a6b2372..00e985d230 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -189,7 +189,7 @@ typedef struct { * @{ */ int spillover_nbits; ///< number of bits of the previous packet's - ///< last superframe preceeding this + ///< last superframe preceding this ///< packet's first full superframe (useful ///< for re-synchronization also) int has_residual_lsps; ///< if set, superframes contain one set of @@ -1805,7 +1805,7 @@ static int synth_superframe(AVCodecContext *ctx, int *got_frame_ptr) s->frame.nb_samples = n_samples; samples = (float *)s->frame.data[0]; - /* Parse frames, optionally preceeded by per-frame (independent) LSPs. */ + /* Parse frames, optionally preceded by per-frame (independent) LSPs. */ for (n = 0; n < 3; n++) { if (!s->has_residual_lsps) { int m; diff --git a/libavcodec/x86/vc1dsp_yasm.asm b/libavcodec/x86/vc1dsp_yasm.asm index 220cc03da3..66f61dba6a 100644 --- a/libavcodec/x86/vc1dsp_yasm.asm +++ b/libavcodec/x86/vc1dsp_yasm.asm @@ -227,7 +227,7 @@ section .text imul r2, 0x01010101 %endmacro -; I dont know why the sign extension is needed... +; I do not know why the sign extension is needed... %macro PSIGNW_SRA_MMX 2 psraw %2, 15 PSIGNW_MMX %1, %2 diff --git a/libavdevice/jack_audio.c b/libavdevice/jack_audio.c index dbe1771ebf..e68559e4d3 100644 --- a/libavdevice/jack_audio.c +++ b/libavdevice/jack_audio.c @@ -271,7 +271,7 @@ static int audio_read_packet(AVFormatContext *context, AVPacket *pkt) } } - /* Wait for a packet comming back from process_callback(), if one isn't available yet */ + /* Wait for a packet coming back from process_callback(), if one isn't available yet */ timeout.tv_sec = av_gettime() / 1000000 + 2; if (sem_timedwait(&self->packet_count, &timeout)) { if (errno == ETIMEDOUT) { diff --git a/libavdevice/timefilter.h b/libavdevice/timefilter.h index c98fd03bba..8cadd8b066 100644 --- a/libavdevice/timefilter.h +++ b/libavdevice/timefilter.h @@ -72,7 +72,7 @@ TimeFilter * ff_timefilter_new(double clock_period, double feedback2_factor, dou * * system_time, in seconds, should be the value of the system clock time, * at (or as close as possible to) the moment the device hardware interrupt - * occured (or any other event the device clock raises at the beginning of a + * occurred (or any other event the device clock raises at the beginning of a * cycle). * * @return the filtered time, in seconds diff --git a/libavformat/avformat.h b/libavformat/avformat.h index ab1cd3fcf1..eff60094b1 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -685,7 +685,8 @@ typedef struct AVStream { /** * last packet in packet_buffer for this stream when muxing. - * used internally, NOT PART OF PUBLIC API, dont read or write from outside of libav* + * Used internally, NOT PART OF PUBLIC API, do not read or + * write from outside of libav* */ struct AVPacketList *last_in_packet_buffer; #endif @@ -709,7 +710,7 @@ typedef struct AVStream { int codec_info_nb_frames; /** - * Stream informations used internally by av_find_stream_info() + * Stream information used internally by av_find_stream_info() */ #define MAX_STD_TIMEBASES (60*12+5) struct { @@ -877,7 +878,7 @@ typedef struct AVFormatContext { /** * Decoding: duration of the stream, in AV_TIME_BASE fractional * seconds. Only set this value if you know none of the individual stream - * durations and also dont set any of them. This is deduced from the + * durations and also do not set any of them. This is deduced from the * AVStream values if not set. */ int64_t duration; diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index d349ffdd70..84466aa8a0 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -361,7 +361,7 @@ static int flv_write_trailer(AVFormatContext *s) file_size = avio_tell(pb); - /* update informations */ + /* update information */ avio_seek(pb, flv->duration_offset, SEEK_SET); put_amf_double(pb, flv->duration / (double)1000); avio_seek(pb, flv->filesize_offset, SEEK_SET); @@ -412,7 +412,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) } if (enc->codec_id == CODEC_ID_H264) { - /* check if extradata looks like mp4 formated */ + /* check if extradata looks like MP4 */ if (enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1) { if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0) return -1; diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 92f25901e5..deb652d60c 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -142,7 +142,7 @@ static void free_geobtag(void *obj) * @param maxread Pointer to maximum number of characters to read from the * AVIOContext. After execution the value is decremented by the number of bytes * actually read. - * @returns 0 if no error occured, dst is uninitialized on error + * @returns 0 if no error occurred, dst is uninitialized on error */ static int decode_str(AVFormatContext *s, AVIOContext *pb, int encoding, uint8_t **dst, int *maxread) diff --git a/libavformat/img2.c b/libavformat/img2.c index 898e6a4ca4..2af561c2ce 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -432,7 +432,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) (!st->codec->extradata_size && AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature error: - av_log(s, AV_LOG_ERROR, "malformated jpeg2000 codestream\n"); + av_log(s, AV_LOG_ERROR, "malformed JPEG 2000 codestream\n"); return -1; } } diff --git a/libavformat/iv8.c b/libavformat/iv8.c index 78f71e82af..4f25441e8c 100644 --- a/libavformat/iv8.c +++ b/libavformat/iv8.c @@ -24,7 +24,7 @@ static int probe(AVProbeData *p) { - // the single file i have starts with that, i dont know if others do too + // the single file I have starts with that, I do not know if others do, too if( p->buf[0] == 1 && p->buf[1] == 1 && p->buf[2] == 3 diff --git a/libavformat/mms.h b/libavformat/mms.h index 36e772c7f9..5235581645 100644 --- a/libavformat/mms.h +++ b/libavformat/mms.h @@ -33,7 +33,7 @@ typedef struct { /** Buffer for outgoing packets. */ /*@{*/ - uint8_t *write_out_ptr; ///< Pointer for writting the buffer. + uint8_t *write_out_ptr; ///< Pointer for writing the buffer. uint8_t out_buffer[512]; ///< Buffer for outgoing packet. /*@}*/ diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 36a799d728..09932f83fb 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -243,7 +243,7 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track) /** * This function writes extradata "as is". - * Extradata must be formated like a valid atom (with size and tag) + * Extradata must be formatted like a valid atom (with size and tag). */ static int mov_write_extradata_tag(AVIOContext *pb, MOVTrack *track) { diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index f7045cee5e..37ffae9f66 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -456,7 +456,7 @@ static inline int get16(const uint8_t **pp, const uint8_t *p_end) return c; } -/* read and allocate a DVB string preceeded by its length */ +/* read and allocate a DVB string preceded by its length */ static char *getstr8(const uint8_t **pp, const uint8_t *p_end) { int len; @@ -1672,7 +1672,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) return 0; p = packet + 4; if (has_adaptation) { - /* skip adapation field */ + /* skip adaptation field */ p += p[0] + 1; } /* if past the end of packet, ignore */ @@ -1750,7 +1750,7 @@ static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size) len = avio_read(pb, buf, TS_PACKET_SIZE); if (len != TS_PACKET_SIZE) return len < 0 ? len : AVERROR_EOF; - /* check paquet sync byte */ + /* check packet sync byte */ if (buf[0] != 0x47) { /* find a new packet start */ avio_seek(pb, -TS_PACKET_SIZE, SEEK_CUR); @@ -1892,7 +1892,7 @@ static int mpegts_read_header(AVFormatContext *s, if (s->iformat == &ff_mpegts_demuxer) { /* normal demux */ - /* first do a scaning to get all the services */ + /* first do a scan to get all the services */ if (pb->seekable && avio_seek(pb, pos, SEEK_SET) < 0) av_log(s, AV_LOG_ERROR, "Unable to seek back to the start\n"); diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index c36c672053..32a759c55b 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -944,7 +944,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) uint32_t state = -1; if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) { - av_log(s, AV_LOG_ERROR, "h264 bitstream malformated, " + av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, " "no startcode found, use -vbsf h264_mp4toannexb\n"); return -1; } diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index a7eb432759..78d3650e03 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -68,7 +68,7 @@ typedef struct { int index; ///< index in mxf_essence_container_uls table const UID *codec_ul; int order; ///< interleaving order if dts are equal - int interlaced; ///< wether picture is interlaced + int interlaced; ///< whether picture is interlaced int temporal_reordering; AVRational aspect_ratio; ///< display aspect ratio int closed_gop; ///< gop is closed, used in mpeg-2 frame parsing diff --git a/libavformat/rdt.c b/libavformat/rdt.c index f492805d13..c06583e105 100644 --- a/libavformat/rdt.c +++ b/libavformat/rdt.c @@ -484,7 +484,7 @@ real_parse_asm_rulebook(AVFormatContext *s, AVStream *orig_st, * is set and once for if it isn't. We only read the first because we * don't care much (that's what the "odd" variable is for). * Each rule contains a set of one or more statements, optionally - * preceeded by a single condition. If there's a condition, the rule + * preceded by a single condition. If there's a condition, the rule * starts with a '#'. Multiple conditions are merged between brackets, * so there are never multiple conditions spread out over separate * statements. Generally, these conditions are bitrate limits (min/max) diff --git a/libavformat/rtp.h b/libavformat/rtp.h index 4f35142afd..e619008007 100644 --- a/libavformat/rtp.h +++ b/libavformat/rtp.h @@ -72,7 +72,7 @@ enum CodecID ff_rtp_codec_id(const char *buf, enum AVMediaType codec_type); #define RTP_VERSION 2 #define RTP_MAX_SDES 256 /**< maximum text length for SDES */ -/* RTCP paquets use 0.5 % of the bandwidth */ +/* RTCP packets use 0.5% of the bandwidth */ #define RTCP_TX_RATIO_NUM 5 #define RTCP_TX_RATIO_DEN 1000 diff --git a/libavformat/udp.c b/libavformat/udp.c index 529114a860..2bdd3dc773 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -372,7 +372,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) goto fail; /* Follow the requested reuse option, unless it's multicast in which - * case enable reuse unless explicitely disabled. + * case enable reuse unless explicitly disabled. */ if (s->reuse_socket || (s->is_multicast && !reuse_specified)) { s->reuse_socket = 1; diff --git a/libavformat/utils.c b/libavformat/utils.c index 1df042f0fe..8b749ad7fc 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -770,7 +770,7 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt) memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE); if(av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){ - //FIXME we dont reduce score to 0 for the case of running out of buffer space in bytes + //FIXME we do not reduce score to 0 for the case of running out of buffer space in bytes set_codec_from_probe_data(s, st, pd, st->probe_packets > 0 ? AVPROBE_SCORE_MAX/4 : 0); if(st->codec->codec_id != CODEC_ID_PROBE){ pd->buf_size=0; @@ -1081,7 +1081,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i+1]); if(pkt->dts == AV_NOPTS_VALUE) pkt->dts= st->pts_buffer[0]; - if(st->codec->codec_id == CODEC_ID_H264){ //we skiped it above so we try here + if(st->codec->codec_id == CODEC_ID_H264){ // we skipped it above so we try here update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); // this should happen on the first packet } if(pkt->dts > st->cur_dts) diff --git a/libavutil/eval.h b/libavutil/eval.h index c485c69fb1..ccb29e7a33 100644 --- a/libavutil/eval.h +++ b/libavutil/eval.h @@ -58,7 +58,7 @@ int av_expr_parse_and_eval(double *res, const char *s, * Parse an expression. * * @param expr a pointer where is put an AVExpr containing the parsed - * value in case of successfull parsing, or NULL otherwise. + * value in case of successful parsing, or NULL otherwise. * The pointed to AVExpr must be freed with av_expr_free() by the user * when it is not needed anymore. * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)" diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index f87721711c..c363fa7965 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -909,7 +909,7 @@ static void reallocBuffers(PPContext *c, int width, int height, int stride, int c->yHistogram[i]= width*height/64*15/256; for(i=0; i<3; i++){ - //Note: The +17*1024 is just there so i do not have to worry about r/w over the end. + //Note: The +17*1024 is just there so I do not have to worry about r/w over the end. reallocAlign((void **)&c->tempBlurred[i], 8, stride*mbHeight*16 + 17*1024); reallocAlign((void **)&c->tempBlurredPast[i], 8, 256*((height+7)&(~7))/2 + 17*1024);//FIXME size } diff --git a/libpostproc/postprocess_internal.h b/libpostproc/postprocess_internal.h index 331a96b2dd..d2c6708d76 100644 --- a/libpostproc/postprocess_internal.h +++ b/libpostproc/postprocess_internal.h @@ -100,7 +100,7 @@ typedef struct PPMode{ int minAllowedY; ///< for brigtness correction int maxAllowedY; ///< for brihtness correction - float maxClippedThreshold; ///< amount of "black" u r willing to loose to get a brightness corrected picture + float maxClippedThreshold; ///< amount of "black" you are willing to lose to get a brightness-corrected picture int maxTmpNoise[3]; ///< for Temporal Noise Reducing filter (Maximal sum of abs differences) diff --git a/tools/patcheck b/tools/patcheck index 285496d6e6..ae2c80b086 100755 --- a/tools/patcheck +++ b/tools/patcheck @@ -67,7 +67,7 @@ $EGREP $OPT '^\+ *(const *|)static' $*| $EGREP --color=always '[^=]= *(0|NULL)[^ cat $TMP hiegrep '# *ifdef * (HAVE|CONFIG)_' 'ifdefs that should be #if' $* -hiegrep '\b(awnser|cant|dont|quantised|quantisation|teh|wont)\b' 'common typos' $* +hiegrep '\b(awnser|cant|dont|wont|usefull|successfull|occured|teh|alot|wether|skiped|heigth|informations|colums|loosy|loosing|seperate|preceed)\b' 'common typos' $* hiegrep 'av_log\( *NULL' 'Missing context in av_log' $* hiegrep '[^sn]printf' 'Please use av_log' $* From e2484fb644b8dc0a0704e4155100c897e6e9739c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 9 Dec 2011 21:19:57 +0200 Subject: [PATCH 02/12] movenc: Use the actual converted sample for RTP hinting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If an annex b bitstream is muxed into mov, the actual written sample is reformatted to mp4 syntax before writing. Currently, the RTP hints that copy data from the normal video track, where the payload data might be offset compared to the original sample that the RTP hinting used (when 3 byte annex b startcodes have been converted into 4 byte mp4 format startcodes). Signed-off-by: Martin Storsjö --- libavformat/movenc.c | 13 +++++++++++-- libavformat/movenc.h | 3 ++- libavformat/movenchint.c | 17 +++++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 09932f83fb..b4f6aeebb4 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2002,6 +2002,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) AVCodecContext *enc = trk->enc; unsigned int samplesInChunk = 0; int size= pkt->size; + uint8_t *reformatted_data = NULL; if (!s->pb->seekable) return 0; /* Can't handle that */ if (!size) return 0; /* Discard 0 sized packets */ @@ -2035,7 +2036,13 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) { /* from x264 or from bytestream h264 */ /* nal reformating needed */ - size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size); + if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) { + ff_avc_parse_nal_units_buf(pkt->data, &reformatted_data, + &size); + avio_write(pb, reformatted_data, size); + } else { + size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size); + } } else { avio_write(pb, pkt->data, size); } @@ -2090,7 +2097,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) avio_flush(pb); if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) - ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry); + ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry, + reformatted_data, size); + av_free(reformatted_data); return 0; } diff --git a/libavformat/movenc.h b/libavformat/movenc.h index bddae459da..9b14f24b7a 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -120,7 +120,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index); int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, - int track_index, int sample); + int track_index, int sample, + uint8_t *sample_data, int sample_size); void ff_mov_close_hinting(MOVTrack *track); #endif /* AVFORMAT_MOVENC_H */ diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index 683d58b7c5..9f5e621a88 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -95,11 +95,12 @@ static void sample_queue_free(HintSampleQueue *queue) * not copied. sample_queue_retain should be called before pkt->data * is reused/freed. */ -static void sample_queue_push(HintSampleQueue *queue, AVPacket *pkt, int sample) +static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size, + int sample) { /* No need to keep track of smaller samples, since describing them * with immediates is more efficient. */ - if (pkt->size <= 14) + if (size <= 14) return; if (!queue->samples || queue->len >= queue->size) { HintSample* samples; @@ -109,8 +110,8 @@ static void sample_queue_push(HintSampleQueue *queue, AVPacket *pkt, int sample) return; queue->samples = samples; } - queue->samples[queue->len].data = pkt->data; - queue->samples[queue->len].size = pkt->size; + queue->samples[queue->len].data = data; + queue->samples[queue->len].size = size; queue->samples[queue->len].sample_number = sample; queue->samples[queue->len].offset = 0; queue->samples[queue->len].own_data = 0; @@ -386,7 +387,8 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data, } int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, - int track_index, int sample) + int track_index, int sample, + uint8_t *sample_data, int sample_size) { MOVMuxContext *mov = s->priv_data; MOVTrack *trk = &mov->tracks[track_index]; @@ -402,7 +404,10 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, if (!rtp_ctx->pb) return AVERROR(ENOMEM); - sample_queue_push(&trk->sample_queue, pkt, sample); + if (sample_data) + sample_queue_push(&trk->sample_queue, sample_data, sample_size, sample); + else + sample_queue_push(&trk->sample_queue, pkt->data, pkt->size, sample); /* Feed the packet to the RTP muxer */ ff_write_chained(rtp_ctx, 0, pkt, s); From 4dbac18e2e43e35fe528b1ce4370b2d9dc06779f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 9 Dec 2011 20:42:52 +0200 Subject: [PATCH 03/12] rtpenc: Simplify code by introducing a separate end pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also remove redundant parentheses. Signed-off-by: Martin Storsjö --- libavformat/rtpenc_h264.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/rtpenc_h264.c b/libavformat/rtpenc_h264.c index 9ca6f7f68e..1a486cf96e 100644 --- a/libavformat/rtpenc_h264.c +++ b/libavformat/rtpenc_h264.c @@ -62,17 +62,17 @@ static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int last void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size) { - const uint8_t *r; + const uint8_t *r, *end = buf1 + size; RTPMuxContext *s = s1->priv_data; s->timestamp = s->cur_timestamp; - r = ff_avc_find_startcode(buf1, buf1 + size); - while (r < buf1 + size) { + r = ff_avc_find_startcode(buf1, end); + while (r < end) { const uint8_t *r1; while(!*(r++)); - r1 = ff_avc_find_startcode(r, buf1 + size); - nal_send(s1, r, r1 - r, (r1 == buf1 + size)); + r1 = ff_avc_find_startcode(r, end); + nal_send(s1, r, r1 - r, r1 == end); r = r1; } } From e0a3c287b41b0d9bb1d6e31de83a8e3ae898ba43 Mon Sep 17 00:00:00 2001 From: Luca Abeni Date: Fri, 9 Dec 2011 11:02:55 +0200 Subject: [PATCH 04/12] rtpenc: Add support for mp4 format h264 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/rtpenc_h264.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/libavformat/rtpenc_h264.c b/libavformat/rtpenc_h264.c index 1a486cf96e..776da83a62 100644 --- a/libavformat/rtpenc_h264.c +++ b/libavformat/rtpenc_h264.c @@ -29,6 +29,21 @@ #include "avc.h" #include "rtpenc.h" +static const uint8_t *avc_mp4_find_startcode(const uint8_t *start, const uint8_t *end, int nal_length_size) +{ + int res = 0; + + if (end - start < nal_length_size) + return NULL; + while (nal_length_size--) + res = (res << 8) | *start++; + + if (start + res > end || res < 0 || start + res < start) + return NULL; + + return start + res; +} + static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int last) { RTPMuxContext *s = s1->priv_data; @@ -66,12 +81,22 @@ void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size) RTPMuxContext *s = s1->priv_data; s->timestamp = s->cur_timestamp; - r = ff_avc_find_startcode(buf1, end); + if (s->nal_length_size) + r = avc_mp4_find_startcode(buf1, end, s->nal_length_size) ? buf1 : end; + else + r = ff_avc_find_startcode(buf1, end); while (r < end) { const uint8_t *r1; - while(!*(r++)); - r1 = ff_avc_find_startcode(r, end); + if (s->nal_length_size) { + r1 = avc_mp4_find_startcode(r, end, s->nal_length_size); + if (!r1) + r1 = end; + r += s->nal_length_size; + } else { + while (!*(r++)); + r1 = ff_avc_find_startcode(r, end); + } nal_send(s1, r, r1 - r, r1 == end); r = r1; } From 0ebd4083e114a3c88c0e74852c10aeaea826d24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 9 Dec 2011 21:00:09 +0200 Subject: [PATCH 05/12] sdp: Restore the original mp4 format h264 extradata if converted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the sdp is generated before the rtp muxer is initialized (e.g. as when called from the rtsp muxer), this has to be done, otherwise the rtp muxer doesn't know that the input really is in mp4 format. Signed-off-by: Martin Storsjö --- libavformat/sdp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libavformat/sdp.c b/libavformat/sdp.c index f0d4253da2..d89591fe80 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -156,6 +156,8 @@ static char *extradata2psets(AVCodecContext *c) char *psets, *p; const uint8_t *r; const char *pset_string = "; sprop-parameter-sets="; + uint8_t *orig_extradata = NULL; + int orig_extradata_size = 0; if (c->extradata_size > MAX_EXTRADATA_SIZE) { av_log(c, AV_LOG_ERROR, "Too much extradata!\n"); @@ -172,6 +174,15 @@ static char *extradata2psets(AVCodecContext *c) return NULL; } + + orig_extradata_size = c->extradata_size; + orig_extradata = av_mallocz(orig_extradata_size + + FF_INPUT_BUFFER_PADDING_SIZE); + if (!orig_extradata) { + av_bitstream_filter_close(bsfc); + return NULL; + } + memcpy(orig_extradata, c->extradata, orig_extradata_size); av_bitstream_filter_filter(bsfc, c, NULL, &dummy_p, &dummy_int, NULL, 0, 0); av_bitstream_filter_close(bsfc); } @@ -179,6 +190,7 @@ static char *extradata2psets(AVCodecContext *c) psets = av_mallocz(MAX_PSET_SIZE); if (psets == NULL) { av_log(c, AV_LOG_ERROR, "Cannot allocate memory for the parameter sets.\n"); + av_free(orig_extradata); return NULL; } memcpy(psets, pset_string, strlen(pset_string)); @@ -208,6 +220,11 @@ static char *extradata2psets(AVCodecContext *c) p += strlen(p); r = r1; } + if (orig_extradata) { + av_free(c->extradata); + c->extradata = orig_extradata; + c->extradata_size = orig_extradata_size; + } return psets; } From 373211d828f351d86908d47828444f620bfd176d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 11 Dec 2011 17:07:04 +0000 Subject: [PATCH 06/12] Remove extraneous semicolons These semicolons cause invalid empty top-level declarations. Signed-off-by: Mans Rullgard --- libavcodec/h264.c | 4 +- libavcodec/h264pred_template.c | 12 ++-- libavcodec/vc1dsp.c | 4 +- libavformat/http.c | 2 +- libavformat/movenc.c | 2 +- libswscale/rgb2rgb.c | 8 +-- libswscale/swscale.c | 120 ++++++++++++++++----------------- libswscale/x86/swscale_mmx.c | 2 +- 8 files changed, 77 insertions(+), 77 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 285aae81e5..631ad96e6b 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2200,8 +2200,8 @@ static av_always_inline void hl_decode_mb_444_internal(H264Context *h, int simpl static void hl_decode_mb_simple_ ## bits(H264Context *h){ \ hl_decode_mb_internal(h, 1, sh); \ } -hl_decode_mb_simple(0, 8); -hl_decode_mb_simple(1, 16); +hl_decode_mb_simple(0, 8) +hl_decode_mb_simple(1, 16) /** * Process a macroblock; this handles edge cases, such as interlacing. diff --git a/libavcodec/h264pred_template.c b/libavcodec/h264pred_template.c index 318b56196d..19100b69a9 100644 --- a/libavcodec/h264pred_template.c +++ b/libavcodec/h264pred_template.c @@ -388,9 +388,9 @@ static void FUNCC(pred16x16_##n##_dc)(uint8_t *_src, int stride){\ PREDICT_16x16_DC(PIXEL_SPLAT_X4(v));\ } -PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1); -PRED16x16_X(128, (1<<(BIT_DEPTH-1))+0); -PRED16x16_X(129, (1<<(BIT_DEPTH-1))+1); +PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1) +PRED16x16_X(128, (1<<(BIT_DEPTH-1))+0) +PRED16x16_X(129, (1<<(BIT_DEPTH-1))+1) static inline void FUNCC(pred16x16_plane_compat)(uint8_t *_src, int _stride, const int svq3, const int rv40){ int i, j, k; @@ -502,9 +502,9 @@ static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, int stride){\ }\ } -PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1); -PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0); -PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1); +PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1) +PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0) +PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1) static void FUNCC(pred8x16_128_dc)(uint8_t *_src, int stride){ FUNCC(pred8x8_128_dc)(_src, stride); diff --git a/libavcodec/vc1dsp.c b/libavcodec/vc1dsp.c index 77725095c3..9bd107cdd9 100644 --- a/libavcodec/vc1dsp.c +++ b/libavcodec/vc1dsp.c @@ -550,8 +550,8 @@ static av_always_inline int vc1_mspel_ ## DIR ## _filter_16bits(const TYPE *src, return 0; /* should not occur */ \ } -VC1_MSPEL_FILTER_16B(ver, uint8_t); -VC1_MSPEL_FILTER_16B(hor, int16_t); +VC1_MSPEL_FILTER_16B(ver, uint8_t) +VC1_MSPEL_FILTER_16B(hor, int16_t) /** Filter used to interpolate fractional pel values diff --git a/libavformat/http.c b/libavformat/http.c index a9b4d5a573..7badf720ed 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -67,7 +67,7 @@ static const AVClass flavor ## _context_class = {\ .item_name = av_default_item_name,\ .option = options,\ .version = LIBAVUTIL_VERSION_INT,\ -}; +} HTTP_CLASS(http); HTTP_CLASS(https); diff --git a/libavformat/movenc.c b/libavformat/movenc.c index b4f6aeebb4..92588007ce 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1286,7 +1286,7 @@ static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, track->enc->height << 16); return updateSize(pb, pos); -}; +} // This box seems important for the psp playback ... without it the movie seems to hang static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track) diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 51cb600e6b..0f07e57683 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -310,8 +310,8 @@ void shuffle_bytes_##a##b##c##d(const uint8_t *src, uint8_t *dst, int src_size) } \ } -DEFINE_SHUFFLE_BYTES(0, 3, 2, 1); -DEFINE_SHUFFLE_BYTES(1, 2, 3, 0); -DEFINE_SHUFFLE_BYTES(3, 0, 1, 2); -DEFINE_SHUFFLE_BYTES(3, 2, 1, 0); +DEFINE_SHUFFLE_BYTES(0, 3, 2, 1) +DEFINE_SHUFFLE_BYTES(1, 2, 3, 0) +DEFINE_SHUFFLE_BYTES(3, 0, 1, 2) +DEFINE_SHUFFLE_BYTES(3, 2, 1, 0) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 975a0bdf1f..116f780efa 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -299,12 +299,12 @@ static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filter filterSize, (const typeX_t **) src, \ (uint16_t *) dest, dstW, is_be, bits); \ } -yuv2NBPS( 9, BE, 1, 10, int16_t); -yuv2NBPS( 9, LE, 0, 10, int16_t); -yuv2NBPS(10, BE, 1, 10, int16_t); -yuv2NBPS(10, LE, 0, 10, int16_t); -yuv2NBPS(16, BE, 1, 16, int32_t); -yuv2NBPS(16, LE, 0, 16, int32_t); +yuv2NBPS( 9, BE, 1, 10, int16_t) +yuv2NBPS( 9, LE, 0, 10, int16_t) +yuv2NBPS(10, BE, 1, 10, int16_t) +yuv2NBPS(10, LE, 0, 10, int16_t) +yuv2NBPS(16, BE, 1, 16, int32_t) +yuv2NBPS(16, LE, 0, 16, int32_t) static void yuv2planeX_8_c(const int16_t *filter, int filterSize, const int16_t **src, uint8_t *dest, int dstW, @@ -489,8 +489,8 @@ static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \ dstW, uvalpha, y, fmt); \ } -YUV2PACKED16WRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE); -YUV2PACKED16WRAPPER(yuv2gray16,, BE, PIX_FMT_GRAY16BE); +YUV2PACKED16WRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE) +YUV2PACKED16WRAPPER(yuv2gray16,, BE, PIX_FMT_GRAY16BE) #define output_pixel(pos, acc) \ if (target == PIX_FMT_MONOBLACK) { \ @@ -618,8 +618,8 @@ static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ y, fmt); \ } -YUV2PACKEDWRAPPER(yuv2mono,, white, PIX_FMT_MONOWHITE); -YUV2PACKEDWRAPPER(yuv2mono,, black, PIX_FMT_MONOBLACK); +YUV2PACKEDWRAPPER(yuv2mono,, white, PIX_FMT_MONOWHITE) +YUV2PACKEDWRAPPER(yuv2mono,, black, PIX_FMT_MONOBLACK) #define output_pixels(pos, Y1, U, Y2, V) \ if (target == PIX_FMT_YUYV422) { \ @@ -730,8 +730,8 @@ yuv2422_1_c_template(SwsContext *c, const int16_t *buf0, #undef output_pixels -YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, PIX_FMT_YUYV422); -YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, PIX_FMT_UYVY422); +YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, PIX_FMT_YUYV422) +YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, PIX_FMT_UYVY422) #define R_B ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? R : B) #define B_R ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? B : R) @@ -912,10 +912,10 @@ yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0, #undef r_b #undef b_r -YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE); -YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE); -YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE); -YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE); +YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE) +YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE) +YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE) +YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE) static av_always_inline void yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, @@ -1212,24 +1212,24 @@ static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ } #if CONFIG_SMALL -YUV2RGBWRAPPER(yuv2rgb,, 32_1, PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); -YUV2RGBWRAPPER(yuv2rgb,, 32, PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); +YUV2RGBWRAPPER(yuv2rgb,, 32_1, PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) +YUV2RGBWRAPPER(yuv2rgb,, 32, PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) #else #if CONFIG_SWSCALE_ALPHA -YUV2RGBWRAPPER(yuv2rgb,, a32_1, PIX_FMT_RGB32_1, 1); -YUV2RGBWRAPPER(yuv2rgb,, a32, PIX_FMT_RGB32, 1); +YUV2RGBWRAPPER(yuv2rgb,, a32_1, PIX_FMT_RGB32_1, 1) +YUV2RGBWRAPPER(yuv2rgb,, a32, PIX_FMT_RGB32, 1) #endif -YUV2RGBWRAPPER(yuv2rgb,, x32_1, PIX_FMT_RGB32_1, 0); -YUV2RGBWRAPPER(yuv2rgb,, x32, PIX_FMT_RGB32, 0); +YUV2RGBWRAPPER(yuv2rgb,, x32_1, PIX_FMT_RGB32_1, 0) +YUV2RGBWRAPPER(yuv2rgb,, x32, PIX_FMT_RGB32, 0) #endif -YUV2RGBWRAPPER(yuv2, rgb, rgb24, PIX_FMT_RGB24, 0); -YUV2RGBWRAPPER(yuv2, rgb, bgr24, PIX_FMT_BGR24, 0); -YUV2RGBWRAPPER(yuv2rgb,, 16, PIX_FMT_RGB565, 0); -YUV2RGBWRAPPER(yuv2rgb,, 15, PIX_FMT_RGB555, 0); -YUV2RGBWRAPPER(yuv2rgb,, 12, PIX_FMT_RGB444, 0); -YUV2RGBWRAPPER(yuv2rgb,, 8, PIX_FMT_RGB8, 0); -YUV2RGBWRAPPER(yuv2rgb,, 4, PIX_FMT_RGB4, 0); -YUV2RGBWRAPPER(yuv2rgb,, 4b, PIX_FMT_RGB4_BYTE, 0); +YUV2RGBWRAPPER(yuv2, rgb, rgb24, PIX_FMT_RGB24, 0) +YUV2RGBWRAPPER(yuv2, rgb, bgr24, PIX_FMT_BGR24, 0) +YUV2RGBWRAPPER(yuv2rgb,, 16, PIX_FMT_RGB565, 0) +YUV2RGBWRAPPER(yuv2rgb,, 15, PIX_FMT_RGB555, 0) +YUV2RGBWRAPPER(yuv2rgb,, 12, PIX_FMT_RGB444, 0) +YUV2RGBWRAPPER(yuv2rgb,, 8, PIX_FMT_RGB8, 0) +YUV2RGBWRAPPER(yuv2rgb,, 4, PIX_FMT_RGB4, 0) +YUV2RGBWRAPPER(yuv2rgb,, 4b, PIX_FMT_RGB4_BYTE, 0) static av_always_inline void yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter, @@ -1323,24 +1323,24 @@ yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter, } #if CONFIG_SMALL -YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); -YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); -YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); -YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); +YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) +YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) +YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) +YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) #else #if CONFIG_SWSCALE_ALPHA -YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, 1); -YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, 1); -YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, 1); -YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, 1); +YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, 1) +YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, 1) +YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, 1) +YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, 1) #endif -YUV2RGBWRAPPERX(yuv2, rgb_full, bgrx32_full, PIX_FMT_BGRA, 0); -YUV2RGBWRAPPERX(yuv2, rgb_full, xbgr32_full, PIX_FMT_ABGR, 0); -YUV2RGBWRAPPERX(yuv2, rgb_full, rgbx32_full, PIX_FMT_RGBA, 0); -YUV2RGBWRAPPERX(yuv2, rgb_full, xrgb32_full, PIX_FMT_ARGB, 0); +YUV2RGBWRAPPERX(yuv2, rgb_full, bgrx32_full, PIX_FMT_BGRA, 0) +YUV2RGBWRAPPERX(yuv2, rgb_full, xbgr32_full, PIX_FMT_ABGR, 0) +YUV2RGBWRAPPERX(yuv2, rgb_full, rgbx32_full, PIX_FMT_RGBA, 0) +YUV2RGBWRAPPERX(yuv2, rgb_full, xrgb32_full, PIX_FMT_ARGB, 0) #endif -YUV2RGBWRAPPERX(yuv2, rgb_full, bgr24_full, PIX_FMT_BGR24, 0); -YUV2RGBWRAPPERX(yuv2, rgb_full, rgb24_full, PIX_FMT_RGB24, 0); +YUV2RGBWRAPPERX(yuv2, rgb_full, bgr24_full, PIX_FMT_BGR24, 0) +YUV2RGBWRAPPERX(yuv2, rgb_full, rgb24_full, PIX_FMT_RGB24, 0) static av_always_inline void fillPlane(uint8_t* plane, int stride, int width, int height, @@ -1440,10 +1440,10 @@ static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \ } -rgb48funcs(rgb, LE, PIX_FMT_RGB48LE); -rgb48funcs(rgb, BE, PIX_FMT_RGB48BE); -rgb48funcs(bgr, LE, PIX_FMT_BGR48LE); -rgb48funcs(bgr, BE, PIX_FMT_BGR48BE); +rgb48funcs(rgb, LE, PIX_FMT_RGB48LE) +rgb48funcs(rgb, BE, PIX_FMT_RGB48BE) +rgb48funcs(bgr, LE, PIX_FMT_BGR48LE) +rgb48funcs(bgr, BE, PIX_FMT_BGR48BE) #define input_pixel(i) ((origin == PIX_FMT_RGBA || origin == PIX_FMT_BGRA || \ origin == PIX_FMT_ARGB || origin == PIX_FMT_ABGR) ? AV_RN32A(&src[(i)*4]) : \ @@ -1555,18 +1555,18 @@ static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \ maskr, maskg, maskb, rsh, gsh, bsh, S); \ } -rgb16_32_wrapper(PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT+8); -rgb16_32_wrapper(PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT+8); -rgb16_32_wrapper(PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT+8); -rgb16_32_wrapper(PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT+8); -rgb16_32_wrapper(PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT+8); -rgb16_32_wrapper(PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT+7); -rgb16_32_wrapper(PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT+8); -rgb16_32_wrapper(PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT+7); -rgb16_32_wrapper(PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT+8); -rgb16_32_wrapper(PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT+7); -rgb16_32_wrapper(PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT+8); -rgb16_32_wrapper(PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT+7); +rgb16_32_wrapper(PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT+8) +rgb16_32_wrapper(PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT+8) +rgb16_32_wrapper(PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT+8) +rgb16_32_wrapper(PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT+8) +rgb16_32_wrapper(PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT+8) +rgb16_32_wrapper(PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT+7) +rgb16_32_wrapper(PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT+8) +rgb16_32_wrapper(PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT+7) +rgb16_32_wrapper(PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT+8) +rgb16_32_wrapper(PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT+7) +rgb16_32_wrapper(PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT+8) +rgb16_32_wrapper(PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT+7) static void abgrToA_c(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused) { diff --git a/libswscale/x86/swscale_mmx.c b/libswscale/x86/swscale_mmx.c index b3f1deae60..15511c6b13 100644 --- a/libswscale/x86/swscale_mmx.c +++ b/libswscale/x86/swscale_mmx.c @@ -181,7 +181,7 @@ extern void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( SwsContext *c, int16_t *data, \ int dstW, const uint8_t *src, \ const int16_t *filter, \ - const int16_t *filterPos, int filterSize); + const int16_t *filterPos, int filterSize) #define SCALE_FUNCS(filter_n, opt) \ SCALE_FUNC(filter_n, 8, 15, opt); \ From 5b3265a7181889b53ff8217c1bdccdf966c86955 Mon Sep 17 00:00:00 2001 From: Andrey Utkin Date: Thu, 8 Dec 2011 21:27:01 +0200 Subject: [PATCH 07/12] lavfi: install libavfilter/vsrc_buffer.h It declares API necessary for filtering apps. Signed-off-by: Anton Khirnov --- libavfilter/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/Makefile b/libavfilter/Makefile index e9eaf9550d..bc05f1ddea 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -3,7 +3,7 @@ FFLIBS = avutil FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec FFLIBS-$(CONFIG_SCALE_FILTER) += swscale -HEADERS = avfilter.h avfiltergraph.h +HEADERS = avfilter.h avfiltergraph.h vsrc_buffer.h OBJS = allfilters.o \ avfilter.o \ From 3383a53e7d0abb9639c3ea3481f0eda9dca61a26 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 27 Nov 2011 14:04:16 +0000 Subject: [PATCH 08/12] lavu: replace int/float punning functions The existing functions defined in intfloat_readwrite.[ch] are both slow and incorrect (infinities are not handled). This introduces a new header with fast, inline conversion functions using direct union punning assuming an IEEE-754 system, an assumption already made throughout the code. The one use of Intel/Motorola extended 80-bit format is replaced by simpler code sufficient under the present constraints (positive normal values). The old functions are marked deprecated and retained for compatibility. Signed-off-by: Mans Rullgard --- libavcodec/binkaudio.c | 6 +-- libavformat/4xm.c | 4 +- libavformat/aiffdec.c | 10 +++-- libavformat/aiffenc.c | 9 +++-- libavformat/cafdec.c | 4 +- libavformat/ffmdec.c | 16 ++++---- libavformat/ffmenc.c | 16 ++++---- libavformat/flvdec.c | 6 +-- libavformat/flvenc.c | 4 +- libavformat/gxfenc.c | 6 +-- libavformat/matroskadec.c | 8 ++-- libavformat/matroskaenc.c | 4 +- libavformat/mov.c | 4 +- libavformat/movenc.c | 4 +- libavformat/nuv.c | 6 +-- libavformat/rtmppkt.c | 8 ++-- libavformat/rtmpproto.c | 6 +-- libavformat/soxdec.c | 6 +-- libavformat/soxenc.c | 6 +-- libavformat/thp.c | 4 +- libavformat/wtv.c | 6 +-- libavutil/intfloat.h | 73 ++++++++++++++++++++++++++++++++++ libavutil/intfloat_readwrite.h | 12 +++--- 23 files changed, 152 insertions(+), 76 deletions(-) create mode 100644 libavutil/intfloat.h diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index 1dceeb74c3..adffc6b2b6 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -35,7 +35,7 @@ #include "dct.h" #include "rdft.h" #include "fmtconvert.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" extern const uint16_t ff_wma_critical_freqs[25]; @@ -193,8 +193,8 @@ static int decode_block(BinkAudioContext *s, int16_t *out, int use_dct) if (s->version_b) { if (get_bits_left(gb) < 64) return AVERROR_INVALIDDATA; - coeffs[0] = av_int2flt(get_bits(gb, 32)) * s->root; - coeffs[1] = av_int2flt(get_bits(gb, 32)) * s->root; + coeffs[0] = av_int2float(get_bits_long(gb, 32)) * s->root; + coeffs[1] = av_int2float(get_bits_long(gb, 32)) * s->root; } else { if (get_bits_left(gb) < 58) return AVERROR_INVALIDDATA; diff --git a/libavformat/4xm.c b/libavformat/4xm.c index 6dc919e1bf..ccbe3add3f 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -28,7 +28,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "avformat.h" #include "internal.h" @@ -131,7 +131,7 @@ static int fourxm_read_header(AVFormatContext *s, size = AV_RL32(&header[i + 4]); if (fourcc_tag == std__TAG) { - fourxm->fps = av_int2flt(AV_RL32(&header[i + 12])); + fourxm->fps = av_int2float(AV_RL32(&header[i + 12])); } else if (fourcc_tag == vtrk_TAG) { /* check that there is enough data */ if (size != vtrk_SIZE) { diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index f54a7ffafe..0e69d02c8c 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/dict.h" #include "avformat.h" #include "internal.h" @@ -88,7 +88,8 @@ static void get_meta(AVFormatContext *s, const char *key, int size) static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec, int size, unsigned version) { - AVExtFloat ext; + int exp; + uint64_t val; double sample_rate; unsigned int num_frames; @@ -99,8 +100,9 @@ static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec, num_frames = avio_rb32(pb); codec->bits_per_coded_sample = avio_rb16(pb); - avio_read(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */ - sample_rate = av_ext2dbl(ext); /* 80 bits BE IEEE extended float */ + exp = avio_rb16(pb); + val = avio_rb64(pb); + sample_rate = ldexp(val, exp - 16383 - 63); codec->sample_rate = sample_rate; size -= 18; diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index df43688d40..2916d26fc6 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "avformat.h" #include "internal.h" #include "aiff.h" @@ -36,7 +36,7 @@ static int aiff_write_header(AVFormatContext *s) AIFFOutputContext *aiff = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *enc = s->streams[0]->codec; - AVExtFloat sample_rate; + uint64_t sample_rate; int aifc = 0; /* First verify if format is ok */ @@ -82,8 +82,9 @@ static int aiff_write_header(AVFormatContext *s) avio_wb16(pb, enc->bits_per_coded_sample); /* Sample size */ - sample_rate = av_dbl2ext((double)enc->sample_rate); - avio_write(pb, (uint8_t*)&sample_rate, sizeof(sample_rate)); + sample_rate = av_double2int(enc->sample_rate); + avio_wb16(pb, (sample_rate >> 52) + (16383 - 1023)); + avio_wb64(pb, UINT64_C(1) << 63 | sample_rate << 11); if (aifc) { avio_wl32(pb, enc->codec_tag); diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 36d7ad431d..4efc40f1af 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -30,7 +30,7 @@ #include "riff.h" #include "isom.h" #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/dict.h" #include "caf.h" @@ -68,7 +68,7 @@ static int read_desc_chunk(AVFormatContext *s) /* parse format description */ st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->sample_rate = av_int2dbl(avio_rb64(pb)); + st->codec->sample_rate = av_int2double(avio_rb64(pb)); st->codec->codec_tag = avio_rb32(pb); flags = avio_rb32(pb); caf->bytes_per_packet = avio_rb32(pb); diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index 114576707e..9cee3ad64f 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -20,7 +20,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "avformat.h" #include "internal.h" #include "ffm.h" @@ -325,10 +325,10 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) codec->rc_max_rate = avio_rb32(pb); codec->rc_min_rate = avio_rb32(pb); codec->rc_buffer_size = avio_rb32(pb); - codec->i_quant_factor = av_int2dbl(avio_rb64(pb)); - codec->b_quant_factor = av_int2dbl(avio_rb64(pb)); - codec->i_quant_offset = av_int2dbl(avio_rb64(pb)); - codec->b_quant_offset = av_int2dbl(avio_rb64(pb)); + codec->i_quant_factor = av_int2double(avio_rb64(pb)); + codec->b_quant_factor = av_int2double(avio_rb64(pb)); + codec->i_quant_offset = av_int2double(avio_rb64(pb)); + codec->b_quant_offset = av_int2double(avio_rb64(pb)); codec->dct_algo = avio_rb32(pb); codec->strict_std_compliance = avio_rb32(pb); codec->max_b_frames = avio_rb32(pb); @@ -340,7 +340,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) codec->mb_decision = avio_rb32(pb); codec->nsse_weight = avio_rb32(pb); codec->frame_skip_cmp = avio_rb32(pb); - codec->rc_buffer_aggressivity = av_int2dbl(avio_rb64(pb)); + codec->rc_buffer_aggressivity = av_int2double(avio_rb64(pb)); codec->codec_tag = avio_rb32(pb); codec->thread_count = avio_r8(pb); codec->coder_type = avio_rb32(pb); @@ -350,8 +350,8 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) codec->keyint_min = avio_rb32(pb); codec->scenechange_threshold = avio_rb32(pb); codec->b_frame_strategy = avio_rb32(pb); - codec->qcompress = av_int2dbl(avio_rb64(pb)); - codec->qblur = av_int2dbl(avio_rb64(pb)); + codec->qcompress = av_int2double(avio_rb64(pb)); + codec->qblur = av_int2double(avio_rb64(pb)); codec->max_qdiff = avio_rb32(pb); codec->refs = avio_rb32(pb); break; diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c index af32e71b7d..d304f57ac4 100644 --- a/libavformat/ffmenc.c +++ b/libavformat/ffmenc.c @@ -20,7 +20,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "avformat.h" #include "internal.h" #include "ffm.h" @@ -137,10 +137,10 @@ static int ffm_write_header(AVFormatContext *s) avio_wb32(pb, codec->rc_max_rate); avio_wb32(pb, codec->rc_min_rate); avio_wb32(pb, codec->rc_buffer_size); - avio_wb64(pb, av_dbl2int(codec->i_quant_factor)); - avio_wb64(pb, av_dbl2int(codec->b_quant_factor)); - avio_wb64(pb, av_dbl2int(codec->i_quant_offset)); - avio_wb64(pb, av_dbl2int(codec->b_quant_offset)); + avio_wb64(pb, av_double2int(codec->i_quant_factor)); + avio_wb64(pb, av_double2int(codec->b_quant_factor)); + avio_wb64(pb, av_double2int(codec->i_quant_offset)); + avio_wb64(pb, av_double2int(codec->b_quant_offset)); avio_wb32(pb, codec->dct_algo); avio_wb32(pb, codec->strict_std_compliance); avio_wb32(pb, codec->max_b_frames); @@ -152,7 +152,7 @@ static int ffm_write_header(AVFormatContext *s) avio_wb32(pb, codec->mb_decision); avio_wb32(pb, codec->nsse_weight); avio_wb32(pb, codec->frame_skip_cmp); - avio_wb64(pb, av_dbl2int(codec->rc_buffer_aggressivity)); + avio_wb64(pb, av_double2int(codec->rc_buffer_aggressivity)); avio_wb32(pb, codec->codec_tag); avio_w8(pb, codec->thread_count); avio_wb32(pb, codec->coder_type); @@ -162,8 +162,8 @@ static int ffm_write_header(AVFormatContext *s) avio_wb32(pb, codec->keyint_min); avio_wb32(pb, codec->scenechange_threshold); avio_wb32(pb, codec->b_frame_strategy); - avio_wb64(pb, av_dbl2int(codec->qcompress)); - avio_wb64(pb, av_dbl2int(codec->qblur)); + avio_wb64(pb, av_double2int(codec->qcompress)); + avio_wb64(pb, av_double2int(codec->qblur)); avio_wb32(pb, codec->max_qdiff); avio_wb32(pb, codec->refs); break; diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 51a8126904..4fc5a4949e 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -26,7 +26,7 @@ #include "libavutil/avstring.h" #include "libavutil/dict.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/mathematics.h" #include "libavcodec/bytestream.h" #include "libavcodec/mpeg4audio.h" @@ -189,7 +189,7 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) { if (avio_r8(ioc) != AMF_DATA_TYPE_NUMBER) goto finish; - num_val = av_int2dbl(avio_rb64(ioc)); + num_val = av_int2double(avio_rb64(ioc)); current_array[i] = num_val; } if (times && filepositions) { @@ -230,7 +230,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst switch(amf_type) { case AMF_DATA_TYPE_NUMBER: - num_val = av_int2dbl(avio_rb64(ioc)); break; + num_val = av_int2double(avio_rb64(ioc)); break; case AMF_DATA_TYPE_BOOL: num_val = avio_r8(ioc); break; case AMF_DATA_TYPE_STRING: diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 84466aa8a0..dfa17e0374 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "avformat.h" #include "flv.h" #include "internal.h" @@ -162,7 +162,7 @@ static void put_avc_eos_tag(AVIOContext *pb, unsigned ts) { static void put_amf_double(AVIOContext *pb, double d) { avio_w8(pb, AMF_DATA_TYPE_NUMBER); - avio_wb64(pb, av_dbl2int(d)); + avio_wb64(pb, av_double2int(d)); } static void put_amf_bool(AVIOContext *pb, int b) { diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 69650c697b..124064fc55 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/mathematics.h" #include "avformat.h" #include "internal.h" @@ -520,8 +520,8 @@ static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc) static int gxf_write_umf_media_audio(AVIOContext *pb, GXFStreamContext *sc) { - avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */ - avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */ + avio_wl64(pb, av_double2int(1)); /* sound level to begin to */ + avio_wl64(pb, av_double2int(1)); /* sound level to begin to */ avio_wl32(pb, 0); /* number of fields over which to ramp up sound level */ avio_wl32(pb, 0); /* number of fields over which to ramp down sound level */ avio_wl32(pb, 0); /* reserved */ diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b61c819ce3..2684d6e6d9 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -38,7 +38,7 @@ #include "rm.h" #include "matroska.h" #include "libavcodec/mpeg4audio.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" #include "libavutil/lzo.h" @@ -624,9 +624,9 @@ static int ebml_read_float(AVIOContext *pb, int size, double *num) if (size == 0) { *num = 0; } else if (size == 4) { - *num= av_int2flt(avio_rb32(pb)); - } else if(size==8){ - *num= av_int2dbl(avio_rb64(pb)); + *num = av_int2float(avio_rb32(pb)); + } else if (size == 8){ + *num = av_int2double(avio_rb64(pb)); } else return AVERROR_INVALIDDATA; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 9f8d5d853b..e93dd65dff 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -29,7 +29,7 @@ #include "avlanguage.h" #include "libavutil/samplefmt.h" #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/mathematics.h" #include "libavutil/random_seed.h" #include "libavutil/lfg.h" @@ -185,7 +185,7 @@ static void put_ebml_float(AVIOContext *pb, unsigned int elementid, double val) { put_ebml_id(pb, elementid); put_ebml_num(pb, 8, 0); - avio_wb64(pb, av_dbl2int(val)); + avio_wb64(pb, av_double2int(val)); } static void put_ebml_binary(AVIOContext *pb, unsigned int elementid, diff --git a/libavformat/mov.c b/libavformat/mov.c index eef53e6d66..d9fb8fb991 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -26,7 +26,7 @@ //#define MOV_EXPORT_ALL_METADATA #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/mathematics.h" #include "libavutil/avstring.h" #include "libavutil/dict.h" @@ -1218,7 +1218,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) avio_rb32(pb); /* bytes per sample */ } else if (version==2) { avio_rb32(pb); /* sizeof struct only */ - st->codec->sample_rate = av_int2dbl(avio_rb64(pb)); /* float 64 */ + st->codec->sample_rate = av_int2double(avio_rb64(pb)); /* float 64 */ st->codec->channels = avio_rb32(pb); avio_rb32(pb); /* always 0x7F000000 */ st->codec->bits_per_coded_sample = avio_rb32(pb); /* bits per channel if sound is uncompressed */ diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 92588007ce..d1076c34c4 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -32,7 +32,7 @@ #include "libavcodec/put_bits.h" #include "internal.h" #include "libavutil/avstring.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavutil/dict.h" @@ -468,7 +468,7 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track) avio_wb16(pb, 0); avio_wb32(pb, 0x00010000); avio_wb32(pb, 72); - avio_wb64(pb, av_dbl2int(track->timescale)); + avio_wb64(pb, av_double2int(track->timescale)); avio_wb32(pb, track->enc->channels); avio_wb32(pb, 0x7F000000); avio_wb32(pb, av_get_bits_per_sample(track->enc->codec_id)); diff --git a/libavformat/nuv.c b/libavformat/nuv.c index ddca4fecff..262c4c58e9 100644 --- a/libavformat/nuv.c +++ b/libavformat/nuv.c @@ -20,7 +20,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "avformat.h" #include "internal.h" #include "riff.h" @@ -140,10 +140,10 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) { avio_rl32(pb); // unused, "desiredheight" avio_r8(pb); // 'P' == progressive, 'I' == interlaced avio_skip(pb, 3); // padding - aspect = av_int2dbl(avio_rl64(pb)); + aspect = av_int2double(avio_rl64(pb)); if (aspect > 0.9999 && aspect < 1.0001) aspect = 4.0 / 3.0; - fps = av_int2dbl(avio_rl64(pb)); + fps = av_int2double(avio_rl64(pb)); // number of packets per stream type, -1 means unknown, e.g. streaming v_packs = avio_rl32(pb); diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index 6bf641a742..8c455a09f0 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -21,7 +21,7 @@ #include "libavcodec/bytestream.h" #include "libavutil/avstring.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "avformat.h" #include "rtmppkt.h" @@ -37,7 +37,7 @@ void ff_amf_write_bool(uint8_t **dst, int val) void ff_amf_write_number(uint8_t **dst, double val) { bytestream_put_byte(dst, AMF_DATA_TYPE_NUMBER); - bytestream_put_be64(dst, av_dbl2int(val)); + bytestream_put_be64(dst, av_double2int(val)); } void ff_amf_write_string(uint8_t **dst, const char *str) @@ -318,7 +318,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, if (size == namelen && !memcmp(data-size, name, namelen)) { switch (*data++) { case AMF_DATA_TYPE_NUMBER: - snprintf(dst, dst_size, "%g", av_int2dbl(AV_RB64(data))); + snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data))); break; case AMF_DATA_TYPE_BOOL: snprintf(dst, dst_size, "%s", *data ? "true" : "false"); @@ -370,7 +370,7 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d return; switch (*data++) { case AMF_DATA_TYPE_NUMBER: - av_log(ctx, AV_LOG_DEBUG, " number %g\n", av_int2dbl(AV_RB64(data))); + av_log(ctx, AV_LOG_DEBUG, " number %g\n", av_int2double(AV_RB64(data))); return; case AMF_DATA_TYPE_BOOL: av_log(ctx, AV_LOG_DEBUG, " bool %d\n", *data); diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 69acd864dc..53d912e3c6 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -26,7 +26,7 @@ #include "libavcodec/bytestream.h" #include "libavutil/avstring.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/lfg.h" #include "libavutil/sha.h" #include "avformat.h" @@ -615,7 +615,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) /* hack for Wowza Media Server, it does not send result for * releaseStream and FCPublish calls */ if (!pkt->data[10]) { - int pkt_id = (int) av_int2dbl(AV_RB64(pkt->data + 11)); + int pkt_id = av_int2double(AV_RB64(pkt->data + 11)); if (pkt_id == rt->create_stream_invoke) rt->state = STATE_CONNECTING; } @@ -626,7 +626,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) if (pkt->data[10] || pkt->data[19] != 5 || pkt->data[20]) { av_log(s, AV_LOG_WARNING, "Unexpected reply on connect()\n"); } else { - rt->main_channel_id = (int) av_int2dbl(AV_RB64(pkt->data + 21)); + rt->main_channel_id = av_int2double(AV_RB64(pkt->data + 21)); } if (rt->is_input) { gen_play(s, rt); diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c index 3e426bea00..1074b3fb2a 100644 --- a/libavformat/soxdec.c +++ b/libavformat/soxdec.c @@ -30,7 +30,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/dict.h" #include "avformat.h" #include "internal.h" @@ -62,14 +62,14 @@ static int sox_read_header(AVFormatContext *s, st->codec->codec_id = CODEC_ID_PCM_S32LE; header_size = avio_rl32(pb); avio_skip(pb, 8); /* sample count */ - sample_rate = av_int2dbl(avio_rl64(pb)); + sample_rate = av_int2double(avio_rl64(pb)); st->codec->channels = avio_rl32(pb); comment_size = avio_rl32(pb); } else { st->codec->codec_id = CODEC_ID_PCM_S32BE; header_size = avio_rb32(pb); avio_skip(pb, 8); /* sample count */ - sample_rate = av_int2dbl(avio_rb64(pb)); + sample_rate = av_int2double(avio_rb64(pb)); st->codec->channels = avio_rb32(pb); comment_size = avio_rb32(pb); } diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index b89203c542..55d5bd98c0 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -30,7 +30,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/dict.h" #include "avformat.h" #include "avio_internal.h" @@ -59,14 +59,14 @@ static int sox_write_header(AVFormatContext *s) ffio_wfourcc(pb, ".SoX"); avio_wl32(pb, sox->header_size); avio_wl64(pb, 0); /* number of samples */ - avio_wl64(pb, av_dbl2int(enc->sample_rate)); + avio_wl64(pb, av_double2int(enc->sample_rate)); avio_wl32(pb, enc->channels); avio_wl32(pb, comment_size); } else if (enc->codec_id == CODEC_ID_PCM_S32BE) { ffio_wfourcc(pb, "XoS."); avio_wb32(pb, sox->header_size); avio_wb64(pb, 0); /* number of samples */ - avio_wb64(pb, av_dbl2int(enc->sample_rate)); + avio_wb64(pb, av_double2int(enc->sample_rate)); avio_wb32(pb, enc->channels); avio_wb32(pb, comment_size); } else { diff --git a/libavformat/thp.c b/libavformat/thp.c index 5b1d180f4b..25efcbba82 100644 --- a/libavformat/thp.c +++ b/libavformat/thp.c @@ -20,7 +20,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "avformat.h" #include "internal.h" @@ -69,7 +69,7 @@ static int thp_read_header(AVFormatContext *s, avio_rb32(pb); /* Max buf size. */ avio_rb32(pb); /* Max samples. */ - thp->fps = av_d2q(av_int2flt(avio_rb32(pb)), INT_MAX); + thp->fps = av_d2q(av_int2float(avio_rb32(pb)), INT_MAX); thp->framecnt = avio_rb32(pb); thp->first_framesz = avio_rb32(pb); avio_rb32(pb); /* Data size. */ diff --git a/libavformat/wtv.c b/libavformat/wtv.c index 0cef6fb240..e4b9ae573a 100644 --- a/libavformat/wtv.c +++ b/libavformat/wtv.c @@ -26,7 +26,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/dict.h" #include "avformat.h" #include "internal.h" @@ -458,7 +458,7 @@ static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value) */ static void oledate_to_iso8601(char *buf, int buf_size, int64_t value) { - time_t t = 631112400LL + 86400*av_int2dbl(value); + time_t t = 631112400LL + 86400*av_int2double(value); strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t)); } @@ -523,7 +523,7 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty else if (!strcmp(key, "WM/WMRVExpirationDate")) oledate_to_iso8601(buf, buf_size, num); else if (!strcmp(key, "WM/WMRVBitrate")) - snprintf(buf, buf_size, "%f", av_int2dbl(num)); + snprintf(buf, buf_size, "%f", av_int2double(num)); else snprintf(buf, buf_size, "%"PRIi64, num); } else if (type == 5 && length == 2) { diff --git a/libavutil/intfloat.h b/libavutil/intfloat.h new file mode 100644 index 0000000000..9db624a6ce --- /dev/null +++ b/libavutil/intfloat.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2011 Mans Rullgard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTFLOAT_H +#define AVUTIL_INTFLOAT_H + +#include +#include "attributes.h" + +union av_intfloat32 { + uint32_t i; + float f; +}; + +union av_intfloat64 { + uint64_t i; + double f; +}; + +/** + * Reinterpret a 32-bit integer as a float. + */ +static av_always_inline float av_int2float(uint32_t i) +{ + union av_intfloat32 v = { .i = i }; + return v.f; +} + +/** + * Reinterpret a float as a 32-bit integer. + */ +static av_always_inline uint32_t av_float2int(float f) +{ + union av_intfloat32 v = { .f = f }; + return v.i; +} + +/** + * Reinterpret a 64-bit integer as a double. + */ +static av_always_inline double av_int2double(uint64_t i) +{ + union av_intfloat64 v = { .i = i }; + return v.f; +} + +/** + * Reinterpret a double as a 64-bit integer. + */ +static av_always_inline uint64_t av_double2int(double f) +{ + union av_intfloat64 v = { .f = f }; + return v.i; +} + +#endif /* AVUTIL_INTFLOAT_H */ diff --git a/libavutil/intfloat_readwrite.h b/libavutil/intfloat_readwrite.h index 10ecbed76c..f093b92cd2 100644 --- a/libavutil/intfloat_readwrite.h +++ b/libavutil/intfloat_readwrite.h @@ -30,11 +30,11 @@ typedef struct AVExtFloat { uint8_t mantissa[8]; } AVExtFloat; -double av_int2dbl(int64_t v) av_const; -float av_int2flt(int32_t v) av_const; -double av_ext2dbl(const AVExtFloat ext) av_const; -int64_t av_dbl2int(double d) av_const; -int32_t av_flt2int(float d) av_const; -AVExtFloat av_dbl2ext(double d) av_const; +attribute_deprecated double av_int2dbl(int64_t v) av_const; +attribute_deprecated float av_int2flt(int32_t v) av_const; +attribute_deprecated double av_ext2dbl(const AVExtFloat ext) av_const; +attribute_deprecated int64_t av_dbl2int(double d) av_const; +attribute_deprecated int32_t av_flt2int(float d) av_const; +attribute_deprecated AVExtFloat av_dbl2ext(double d) av_const; #endif /* AVUTIL_INTFLOAT_READWRITE_H */ From a09bb3ba5e018b81a659c199a84cd1d80c07d869 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 5 Dec 2011 15:38:10 +0000 Subject: [PATCH 09/12] lavc: avoid invalid memcpy() in avcodec_default_release_buffer() When the buf and last pointers are equal, the FFSWAP() results in an invalid call to memcpy() with same source and destination on some targets. Although assigning a struct to itself is valid C99, gcc does not check for this before calling memcpy(). See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667 Signed-off-by: Mans Rullgard --- libavcodec/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 04909cf959..68fc525184 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -509,7 +509,8 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ avci->buffer_count--; last = &avci->buffer[avci->buffer_count]; - FFSWAP(InternalBuffer, *buf, *last); + if (buf != last) + FFSWAP(InternalBuffer, *buf, *last); } for (i = 0; i < AV_NUM_DATA_POINTERS; i++) { From 4424fe9c029ccefc5868823b4967c792e51487f3 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 10 Dec 2011 15:51:25 +0000 Subject: [PATCH 10/12] wmapro: use av_float2int() Signed-off-by: Mans Rullgard --- libavcodec/wmaprodec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index b947eb800f..a1b82db60a 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -86,6 +86,7 @@ * subframe in order to reconstruct the output samples. */ +#include "libavutil/intfloat.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "internal.h" @@ -823,8 +824,8 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); if (v1 == HUFF_VEC1_SIZE - 1) v1 += ff_wma_get_large_val(&s->gb); - vals[i ] = ((av_alias32){ .f32 = v0 }).u32; - vals[i+1] = ((av_alias32){ .f32 = v1 }).u32; + vals[i ] = av_float2int(v0); + vals[i+1] = av_float2int(v1); } else { vals[i] = fval_tab[symbol_to_vec2[idx] >> 4 ]; vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF]; From b11ce85664caa69d6117e692c7ac49be4f7493cc Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sat, 10 Dec 2011 16:59:55 -0500 Subject: [PATCH 11/12] avplay: don't request a stereo downmix Multi-channel output works just fine for me with SDL 1.2.14. --- avplay.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/avplay.c b/avplay.c index 69cd6179f9..fd9774ef32 100644 --- a/avplay.c +++ b/avplay.c @@ -2175,15 +2175,6 @@ static int stream_component_open(VideoState *is, int stream_index) opts = filter_codec_opts(codec_opts, avctx->codec_id, ic, ic->streams[stream_index]); - /* prepare audio output */ - if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { - if (avctx->channels > 0) { - avctx->request_channels = FFMIN(2, avctx->channels); - } else { - avctx->request_channels = 2; - } - } - codec = avcodec_find_decoder(avctx->codec_id); avctx->debug_mv = debug_mv; avctx->debug = debug; From 599b4c6efddaed33b1667c386b34b07729ba732b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 11 Dec 2011 21:41:59 +0000 Subject: [PATCH 12/12] x86: cabac: replace explicit memory references with "m" operands This replaces the explicit offset(reg) memory references with "m" operands for the same locations. As a result, one fewer register operand is needed for these inline asm statements. Signed-off-by: Mans Rullgard --- libavcodec/x86/cabac.h | 45 ++++++++++++++++++-------------------- libavcodec/x86/h264_i386.h | 31 +++++++++++++------------- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index 5da421a90a..d0d1332094 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -27,7 +27,7 @@ #include "config.h" #if HAVE_FAST_CMOV -#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ +#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, lowword, range, tmp)\ "mov "tmp" , %%ecx \n\t"\ "shl $17 , "tmp" \n\t"\ "cmp "low" , "tmp" \n\t"\ @@ -37,7 +37,7 @@ "xor %%ecx , "ret" \n\t"\ "sub "tmp" , "low" \n\t" #else /* HAVE_FAST_CMOV */ -#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ +#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, lowword, range, tmp)\ "mov "tmp" , %%ecx \n\t"\ "shl $17 , "tmp" \n\t"\ "sub "low" , "tmp" \n\t"\ @@ -51,14 +51,13 @@ "xor "tmp" , "ret" \n\t" #endif /* HAVE_FAST_CMOV */ -#define BRANCHLESS_GET_CABAC(ret, cabac, statep, low, lowword, range, tmp, tmpbyte, byte) \ +#define BRANCHLESS_GET_CABAC(ret, statep, low, lowword, range, tmp, tmpbyte, byte) \ "movzbl "statep" , "ret" \n\t"\ "mov "range" , "tmp" \n\t"\ "and $0xC0 , "range" \n\t"\ "movzbl "MANGLE(ff_h264_lps_range)"("ret", "range", 2), "range" \n\t"\ "sub "range" , "tmp" \n\t"\ - BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, \ - range, tmp) \ + BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, lowword, range, tmp) \ "movzbl " MANGLE(ff_h264_norm_shift) "("range"), %%ecx \n\t"\ "shl %%cl , "range" \n\t"\ "movzbl "MANGLE(ff_h264_mlps_state)"+128("ret"), "tmp" \n\t"\ @@ -66,8 +65,8 @@ "mov "tmpbyte" , "statep" \n\t"\ "test "lowword" , "lowword" \n\t"\ " jnz 1f \n\t"\ - "mov "byte"("cabac"), %%"REG_c" \n\t"\ - "add"OPSIZE" $2 , "byte "("cabac") \n\t"\ + "mov "byte" , %%"REG_c" \n\t"\ + "add"OPSIZE" $2 , "byte" \n\t"\ "movzwl (%%"REG_c") , "tmp" \n\t"\ "lea -1("low") , %%ecx \n\t"\ "xor "low" , %%ecx \n\t"\ @@ -82,7 +81,7 @@ "add "tmp" , "low" \n\t"\ "1: \n\t" -#if HAVE_7REGS && !defined(BROKEN_RELOCATIONS) +#if HAVE_6REGS && !defined(BROKEN_RELOCATIONS) #define get_cabac_inline get_cabac_inline_x86 static av_always_inline int get_cabac_inline_x86(CABACContext *c, uint8_t *const state) @@ -90,24 +89,24 @@ static av_always_inline int get_cabac_inline_x86(CABACContext *c, int bit, tmp; __asm__ volatile( - BRANCHLESS_GET_CABAC("%0", "%5", "(%4)", "%1", "%w1", "%2", - "%3", "%b3", "%a6") - :"=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp) - :"r"(state), "r"(c), - "i"(offsetof(CABACContext, bytestream)) + BRANCHLESS_GET_CABAC("%0", "(%5)", "%1", "%w1", "%2", + "%3", "%b3", "%4") + :"=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp), + "+m"(c->bytestream) + :"r"(state) : "%"REG_c, "memory" ); return bit & 1; } -#endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ +#endif /* HAVE_6REGS && !defined(BROKEN_RELOCATIONS) */ #define get_cabac_bypass_sign get_cabac_bypass_sign_x86 static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) { x86_reg tmp; __asm__ volatile( - "movl %a3(%2), %k1 \n\t" - "movl %a4(%2), %%eax \n\t" + "movl %4, %k1 \n\t" + "movl %2, %%eax \n\t" "shl $17, %k1 \n\t" "add %%eax, %%eax \n\t" "sub %k1, %%eax \n\t" @@ -118,22 +117,20 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) "sub %%edx, %%ecx \n\t" "test %%ax, %%ax \n\t" " jnz 1f \n\t" - "mov %a5(%2), %1 \n\t" + "mov %3, %1 \n\t" "subl $0xFFFF, %%eax \n\t" "movzwl (%1), %%edx \n\t" "bswap %%edx \n\t" "shrl $15, %%edx \n\t" "add $2, %1 \n\t" "addl %%edx, %%eax \n\t" - "mov %1, %a5(%2) \n\t" + "mov %1, %3 \n\t" "1: \n\t" - "movl %%eax, %a4(%2) \n\t" + "movl %%eax, %2 \n\t" - :"+c"(val), "=&r"(tmp) - :"r"(c), - "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), - "i"(offsetof(CABACContext, bytestream)) - : "%eax", "%edx", "memory" + :"+c"(val), "=&r"(tmp), "+m"(c->low), "+m"(c->bytestream) + :"m"(c->range) + : "%eax", "%edx" ); return val; } diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 7a361cdb37..50e80d0f7a 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -36,7 +36,7 @@ //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet //as that would make optimization work hard) -#if HAVE_7REGS && !defined(BROKEN_RELOCATIONS) +#if HAVE_6REGS && !defined(BROKEN_RELOCATIONS) static int decode_significance_x86(CABACContext *c, int max_coeff, uint8_t *significant_coeff_ctx_base, int *index, x86_reg last_off){ @@ -48,15 +48,15 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, __asm__ volatile( "2: \n\t" - BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3", - "%w3", "%5", "%k0", "%b0", "%a11") + BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", + "%w3", "%5", "%k0", "%b0", "%6") "test $1, %4 \n\t" " jz 3f \n\t" "add %10, %1 \n\t" - BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3", - "%w3", "%5", "%k0", "%b0", "%a11") + BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", + "%w3", "%5", "%k0", "%b0", "%6") "sub %10, %1 \n\t" "mov %2, %0 \n\t" @@ -81,9 +81,9 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "add %9, %k0 \n\t" "shr $2, %k0 \n\t" :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), - "+&r"(c->low), "=&r"(bit), "+&r"(c->range) - :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), - "i"(offsetof(CABACContext, bytestream)) + "+&r"(c->low), "=&r"(bit), "+&r"(c->range), + "+m"(c->bytestream) + :"m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off) : "%"REG_c, "memory" ); return coeff_count; @@ -105,8 +105,8 @@ static int decode_significance_8x8_x86(CABACContext *c, "movzbl (%0, %6), %k6 \n\t" "add %9, %6 \n\t" - BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3", - "%w3", "%5", "%k0", "%b0", "%a12") + BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", + "%w3", "%5", "%k0", "%b0", "%7") "mov %1, %k6 \n\t" "test $1, %4 \n\t" @@ -115,8 +115,8 @@ static int decode_significance_8x8_x86(CABACContext *c, "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t" "add %11, %6 \n\t" - BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3", - "%w3", "%5", "%k0", "%b0", "%a12") + BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", + "%w3", "%5", "%k0", "%b0", "%7") "mov %2, %0 \n\t" "mov %1, %k6 \n\t" @@ -138,13 +138,12 @@ static int decode_significance_8x8_x86(CABACContext *c, "addl %8, %k0 \n\t" "shr $2, %k0 \n\t" :"=&q"(coeff_count),"+m"(last), "+m"(index), "+&r"(c->low), "=&r"(bit), - "+&r"(c->range), "=&r"(state) - :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base), - "i"(offsetof(CABACContext, bytestream)) + "+&r"(c->range), "=&r"(state), "+m"(c->bytestream) + :"m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base) : "%"REG_c, "memory" ); return coeff_count; } -#endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ +#endif /* HAVE_6REGS && !defined(BROKEN_RELOCATIONS) */ #endif /* AVCODEC_X86_H264_I386_H */