From ae88e9cf99837e5eec811c817a17b2cbc9724a01 Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Sun, 5 Jun 2011 01:28:43 +0900 Subject: mov: Fix empty edit detection. --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ab5c4e2db9..c720440472 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2193,7 +2193,7 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) time = avio_rb64(pb); } else { duration = avio_rb32(pb); /* segment duration */ - time = avio_rb32(pb); /* media time */ + time = (int32_t)avio_rb32(pb); /* media time */ } avio_rb32(pb); /* Media rate */ if (i == 0 && time >= -1) { -- cgit v1.2.3 From ea6331f8bbaf3343faec6ffe77a6218a016a3af5 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 20 Jun 2011 10:24:33 -0400 Subject: h264-mt: fix deadlock in packets with multiple slices (e.g. MP4). --- libavcodec/h264.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index b42468a781..dc4acb8379 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3685,6 +3685,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ switch (hx->nal_unit_type) { case NAL_SPS: case NAL_PPS: + case NAL_IDR_SLICE: + case NAL_SLICE: nals_needed = nal_index; } continue; -- cgit v1.2.3 From 07935318598722e6ffe0f9980010a96f076d7152 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 20 Jun 2011 12:20:54 +0200 Subject: Bump major version for b8e893399ff8755721dc117695ec5ff183c1e07b On architectures such as x86 (both 32 bit and 64bit), the stack element size is fixed, which maintains alignment. Here, this change does not break anything. However, we also support also other architectures where this property is not maintained and therefore, applications will crash horribly. This change effectively forces all applications to be recompiled against libswscale. --- libswscale/swscale.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libswscale/swscale.h b/libswscale/swscale.h index b0ad912a08..2aa5e50ab2 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -29,8 +29,8 @@ #include "libavutil/avutil.h" -#define LIBSWSCALE_VERSION_MAJOR 1 -#define LIBSWSCALE_VERSION_MINOR 1 +#define LIBSWSCALE_VERSION_MAJOR 2 +#define LIBSWSCALE_VERSION_MINOR 0 #define LIBSWSCALE_VERSION_MICRO 0 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ @@ -48,10 +48,10 @@ * They may change, break or disappear at any time. */ #ifndef FF_API_SWS_GETCONTEXT -#define FF_API_SWS_GETCONTEXT (LIBSWSCALE_VERSION_MAJOR < 2) +#define FF_API_SWS_GETCONTEXT (LIBSWSCALE_VERSION_MAJOR < 3) #endif #ifndef FF_API_SWS_CPU_CAPS -#define FF_API_SWS_CPU_CAPS (LIBSWSCALE_VERSION_MAJOR < 2) +#define FF_API_SWS_CPU_CAPS (LIBSWSCALE_VERSION_MAJOR < 3) #endif /** -- cgit v1.2.3 From 3fd53defaa64e1a9295e88767088542b148616bd Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 16 May 2011 20:11:50 +0200 Subject: drawtext: fix strftime() text expansion The feature was dropped after the filter was partially rewritten and recommitted. Signed-off-by: Anton Khirnov --- libavfilter/vf_drawtext.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 8b28be9d9c..f47461f932 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -49,9 +49,11 @@ typedef struct { const AVClass *class; uint8_t *fontfile; ///< font to be used uint8_t *text; ///< text to be drawn - uint8_t *text_priv; ///< used to detect whether text changed + uint8_t *expanded_text; ///< used to contain the strftime()-expanded text + size_t expanded_text_size; ///< size in bytes of the expanded_text buffer int ft_load_flags; ///< flags used for loading fonts, see FT_LOAD_* FT_Vector *positions; ///< positions for each element in the text + size_t nb_positions; ///< number of elements of positions array char *textfile; ///< file with text to be drawn unsigned int x; ///< x position to start drawing text unsigned int y; ///< y position to start drawing text @@ -349,6 +351,7 @@ static av_cold void uninit(AVFilterContext *ctx) av_freep(&dtext->fontfile); av_freep(&dtext->text); + av_freep(&dtext->expanded_text); av_freep(&dtext->fontcolor_string); av_freep(&dtext->boxcolor_string); av_freep(&dtext->positions); @@ -517,7 +520,7 @@ static inline int is_newline(uint32_t c) static int draw_glyphs(DrawTextContext *dtext, AVFilterBufferRef *picref, int width, int height, const uint8_t rgbcolor[4], const uint8_t yuvcolor[4], int x, int y) { - char *text = dtext->text; + char *text = HAVE_LOCALTIME_R ? dtext->expanded_text : dtext->text; uint32_t code = 0; int i; uint8_t *p; @@ -559,45 +562,51 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref, uint32_t code = 0, prev_code = 0; int x = 0, y = 0, i = 0, ret; int text_height, baseline; + char *text = dtext->text; uint8_t *p; - int str_w = 0; + int str_w = 0, len; int y_min = 32000, y_max = -32000; FT_Vector delta; Glyph *glyph = NULL, *prev_glyph = NULL; Glyph dummy = { 0 }; - if (dtext->text != dtext->text_priv) { #if HAVE_LOCALTIME_R time_t now = time(0); struct tm ltime; - uint8_t *buf = NULL; - int buflen = 2*strlen(dtext->text) + 1, len; + uint8_t *buf = dtext->expanded_text; + int buf_size = dtext->expanded_text_size; + + if (!buf) { + buf_size = 2*strlen(dtext->text)+1; + buf = av_malloc(buf_size); + } localtime_r(&now, <ime); - while ((buf = av_realloc(buf, buflen))) { + do { *buf = 1; - if ((len = strftime(buf, buflen, dtext->text, <ime)) != 0 || *buf == 0) + if (strftime(buf, buf_size, dtext->text, <ime) != 0 || *buf == 0) break; - buflen *= 2; - } + buf_size *= 2; + } while ((buf = av_realloc(buf, buf_size))); + if (!buf) return AVERROR(ENOMEM); - av_freep(&dtext->text); - dtext->text = dtext->text_priv = buf; -#else - dtext->text_priv = dtext->text; + text = dtext->expanded_text = buf; + dtext->expanded_text_size = buf_size; #endif - if (!(dtext->positions = av_realloc(dtext->positions, - strlen(dtext->text)*sizeof(*dtext->positions)))) + if ((len = strlen(text)) > dtext->nb_positions) { + if (!(dtext->positions = + av_realloc(dtext->positions, len*sizeof(*dtext->positions)))) return AVERROR(ENOMEM); + dtext->nb_positions = len; } x = dtext->x; y = dtext->y; /* load and cache glyphs */ - for (i = 0, p = dtext->text; *p; i++) { + for (i = 0, p = text; *p; i++) { GET_UTF8(code, *p++, continue;); /* get glyph */ @@ -614,7 +623,7 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref, /* compute and save position for each glyph */ glyph = NULL; - for (i = 0, p = dtext->text; *p; i++) { + for (i = 0, p = text; *p; i++) { GET_UTF8(code, *p++, continue;); /* skip the \n in the sequence \r\n */ -- cgit v1.2.3 From 53a715f576bb4618f91a2f6caba995c48239a5f5 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 16 May 2011 23:48:00 +0200 Subject: drawtext: reindent after the previous commit Signed-off-by: Anton Khirnov --- libavfilter/vf_drawtext.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index f47461f932..7a77d4fa9e 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -571,29 +571,29 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref, Glyph dummy = { 0 }; #if HAVE_LOCALTIME_R - time_t now = time(0); - struct tm ltime; - uint8_t *buf = dtext->expanded_text; - int buf_size = dtext->expanded_text_size; - - if (!buf) { - buf_size = 2*strlen(dtext->text)+1; - buf = av_malloc(buf_size); - } + time_t now = time(0); + struct tm ltime; + uint8_t *buf = dtext->expanded_text; + int buf_size = dtext->expanded_text_size; + + if (!buf) { + buf_size = 2*strlen(dtext->text)+1; + buf = av_malloc(buf_size); + } - localtime_r(&now, <ime); + localtime_r(&now, <ime); - do { - *buf = 1; - if (strftime(buf, buf_size, dtext->text, <ime) != 0 || *buf == 0) - break; - buf_size *= 2; - } while ((buf = av_realloc(buf, buf_size))); + do { + *buf = 1; + if (strftime(buf, buf_size, dtext->text, <ime) != 0 || *buf == 0) + break; + buf_size *= 2; + } while ((buf = av_realloc(buf, buf_size))); - if (!buf) - return AVERROR(ENOMEM); - text = dtext->expanded_text = buf; - dtext->expanded_text_size = buf_size; + if (!buf) + return AVERROR(ENOMEM); + text = dtext->expanded_text = buf; + dtext->expanded_text_size = buf_size; #endif if ((len = strlen(text)) > dtext->nb_positions) { if (!(dtext->positions = -- cgit v1.2.3 From 702a62a1c6b97a8befa114da4ab4aa2b541352af Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 16 May 2011 23:44:35 +0200 Subject: drawtext: add braces around initialisers for option defaults MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warnings of the type: vf_drawtext.c:NNN: warning: missing braces around initializer vf_drawtext.c:NNN: warning: (near initialization for ‘drawtext_options[X].default_val’) Signed-off-by: Anton Khirnov --- libavfilter/vf_drawtext.c | 58 +++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 7a77d4fa9e..a3adaa7dfc 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -86,37 +86,37 @@ typedef struct { #define OFFSET(x) offsetof(DrawTextContext, x) static const AVOption drawtext_options[]= { -{"fontfile", "set font file", OFFSET(fontfile), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX }, -{"text", "set text", OFFSET(text), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX }, -{"textfile", "set text file", OFFSET(textfile), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX }, -{"fontcolor","set foreground color", OFFSET(fontcolor_string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX }, -{"boxcolor", "set box color", OFFSET(boxcolor_string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX }, -{"shadowcolor", "set shadow color", OFFSET(shadowcolor_string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX }, -{"box", "set box", OFFSET(draw_box), FF_OPT_TYPE_INT, 0, 0, 1 }, -{"fontsize", "set font size", OFFSET(fontsize), FF_OPT_TYPE_INT, 16, 1, 72 }, -{"x", "set x", OFFSET(x), FF_OPT_TYPE_INT, 0, 0, INT_MAX }, -{"y", "set y", OFFSET(y), FF_OPT_TYPE_INT, 0, 0, INT_MAX }, -{"shadowx", "set x", OFFSET(shadowx), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX }, -{"shadowy", "set y", OFFSET(shadowy), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX }, -{"tabsize", "set tab size", OFFSET(tabsize), FF_OPT_TYPE_INT, 4, 0, INT_MAX }, +{"fontfile", "set font file", OFFSET(fontfile), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, +{"text", "set text", OFFSET(text), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, +{"textfile", "set text file", OFFSET(textfile), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, +{"fontcolor","set foreground color", OFFSET(fontcolor_string), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, +{"boxcolor", "set box color", OFFSET(boxcolor_string), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, +{"shadowcolor", "set shadow color", OFFSET(shadowcolor_string), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, +{"box", "set box", OFFSET(draw_box), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1 }, +{"fontsize", "set font size", OFFSET(fontsize), FF_OPT_TYPE_INT, {.dbl=16}, 1, 72 }, +{"x", "set x", OFFSET(x), FF_OPT_TYPE_INT, {.dbl=0}, 0, INT_MAX }, +{"y", "set y", OFFSET(y), FF_OPT_TYPE_INT, {.dbl=0}, 0, INT_MAX }, +{"shadowx", "set x", OFFSET(shadowx), FF_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, +{"shadowy", "set y", OFFSET(shadowy), FF_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, +{"tabsize", "set tab size", OFFSET(tabsize), FF_OPT_TYPE_INT, {.dbl=4}, 0, INT_MAX }, /* FT_LOAD_* flags */ -{"ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), FF_OPT_TYPE_FLAGS, FT_LOAD_DEFAULT|FT_LOAD_RENDER, 0, INT_MAX, 0, "ft_load_flags" }, -{"default", "set default", 0, FF_OPT_TYPE_CONST, FT_LOAD_DEFAULT, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_scale", "set no_scale", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_SCALE, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_hinting", "set no_hinting", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_HINTING, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"render", "set render", 0, FF_OPT_TYPE_CONST, FT_LOAD_RENDER, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_bitmap", "set no_bitmap", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_BITMAP, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"vertical_layout", "set vertical_layout", 0, FF_OPT_TYPE_CONST, FT_LOAD_VERTICAL_LAYOUT, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"force_autohint", "set force_autohint", 0, FF_OPT_TYPE_CONST, FT_LOAD_FORCE_AUTOHINT, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"crop_bitmap", "set crop_bitmap", 0, FF_OPT_TYPE_CONST, FT_LOAD_CROP_BITMAP, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"pedantic", "set pedantic", 0, FF_OPT_TYPE_CONST, FT_LOAD_PEDANTIC, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"ignore_global_advance_width", "set ignore_global_advance_width", 0, FF_OPT_TYPE_CONST, FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_recurse", "set no_recurse", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_RECURSE, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"ignore_transform", "set ignore_transform", 0, FF_OPT_TYPE_CONST, FT_LOAD_IGNORE_TRANSFORM, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"monochrome", "set monochrome", 0, FF_OPT_TYPE_CONST, FT_LOAD_MONOCHROME, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"linear_design", "set linear_design", 0, FF_OPT_TYPE_CONST, FT_LOAD_LINEAR_DESIGN, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_autohint", "set no_autohint", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_AUTOHINT, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), FF_OPT_TYPE_FLAGS, {.dbl=FT_LOAD_DEFAULT|FT_LOAD_RENDER}, 0, INT_MAX, 0, "ft_load_flags" }, +{"default", "set default", 0, FF_OPT_TYPE_CONST, {FT_LOAD_DEFAULT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_scale", "set no_scale", 0, FF_OPT_TYPE_CONST, {FT_LOAD_NO_SCALE}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_hinting", "set no_hinting", 0, FF_OPT_TYPE_CONST, {FT_LOAD_NO_HINTING}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"render", "set render", 0, FF_OPT_TYPE_CONST, {FT_LOAD_RENDER}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_bitmap", "set no_bitmap", 0, FF_OPT_TYPE_CONST, {FT_LOAD_NO_BITMAP}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"vertical_layout", "set vertical_layout", 0, FF_OPT_TYPE_CONST, {FT_LOAD_VERTICAL_LAYOUT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"force_autohint", "set force_autohint", 0, FF_OPT_TYPE_CONST, {FT_LOAD_FORCE_AUTOHINT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"crop_bitmap", "set crop_bitmap", 0, FF_OPT_TYPE_CONST, {FT_LOAD_CROP_BITMAP}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"pedantic", "set pedantic", 0, FF_OPT_TYPE_CONST, {FT_LOAD_PEDANTIC}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"ignore_global_advance_width", "set ignore_global_advance_width", 0, FF_OPT_TYPE_CONST, {FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_recurse", "set no_recurse", 0, FF_OPT_TYPE_CONST, {FT_LOAD_NO_RECURSE}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"ignore_transform", "set ignore_transform", 0, FF_OPT_TYPE_CONST, {FT_LOAD_IGNORE_TRANSFORM}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"monochrome", "set monochrome", 0, FF_OPT_TYPE_CONST, {FT_LOAD_MONOCHROME}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"linear_design", "set linear_design", 0, FF_OPT_TYPE_CONST, {FT_LOAD_LINEAR_DESIGN}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_autohint", "set no_autohint", 0, FF_OPT_TYPE_CONST, {FT_LOAD_NO_AUTOHINT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, {NULL}, }; -- cgit v1.2.3 From 5a0a6ae639ac791ddebce64e2c316186d1db575c Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 21 Apr 2011 10:31:48 +0200 Subject: ocv: replace FF_INTERNAL_MEM_TYPE_MAX_VALUE with SIZE_MAX Fix compilatin after removal of FF_INTERNAL_MEM_TYPE_MAX_VALUE. Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- libavfilter/vf_libopencv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index 509b1d96dc..5a52f246ba 100644 --- a/libavfilter/vf_libopencv.c +++ b/libavfilter/vf_libopencv.c @@ -158,7 +158,7 @@ static int read_shape_from_file(int *cols, int *rows, int **values, const char * } w++; } - if (*rows > (FF_INTERNAL_MEM_TYPE_MAX_VALUE / (sizeof(int)) / *cols)) { + if (*rows > (SIZE_MAX / sizeof(int) / *cols)) { av_log(log_ctx, AV_LOG_ERROR, "File with size %dx%d is too big\n", *rows, *cols); return AVERROR_INVALIDDATA; -- cgit v1.2.3 From 3a07f5a47a16bef86faab99bc02d2fd0f396afe8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 18 Jun 2011 02:44:17 +0200 Subject: qdm2: Fix alignment of local array. Fixes ticket270 Signed-off-by: Michael Niedermayer Signed-off-by: Anton Khirnov --- libavcodec/qdm2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 53ee304a28..86847adc10 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -175,6 +175,7 @@ typedef struct { DECLARE_ALIGNED(32, float, synth_buf)[MPA_MAX_CHANNELS][512*2]; int synth_buf_offset[MPA_MAX_CHANNELS]; DECLARE_ALIGNED(32, float, sb_samples)[MPA_MAX_CHANNELS][128][SBLIMIT]; + DECLARE_ALIGNED(32, float, samples)[MPA_MAX_CHANNELS * MPA_FRAME_SIZE]; /// Mixed temporary data used in decoding float tone_level[MPA_MAX_CHANNELS][30][64]; @@ -1598,7 +1599,6 @@ static void qdm2_calculate_fft (QDM2Context *q, int channel, int sub_packet) */ static void qdm2_synthesis_filter (QDM2Context *q, int index) { - float samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE]; int i, k, ch, sb_used, sub_sampling, dither_state = 0; /* copy sb_samples */ @@ -1610,7 +1610,7 @@ static void qdm2_synthesis_filter (QDM2Context *q, int index) q->sb_samples[ch][(8 * index) + i][k] = 0; for (ch = 0; ch < q->nb_channels; ch++) { - float *samples_ptr = samples + ch; + float *samples_ptr = q->samples + ch; for (i = 0; i < 8; i++) { ff_mpa_synth_filter_float(&q->mpadsp, @@ -1627,7 +1627,7 @@ static void qdm2_synthesis_filter (QDM2Context *q, int index) for (ch = 0; ch < q->channels; ch++) for (i = 0; i < q->frame_size; i++) - q->output_buffer[q->channels * i + ch] += (1 << 23) * samples[q->nb_channels * sub_sampling * i + ch]; + q->output_buffer[q->channels * i + ch] += (1 << 23) * q->samples[q->nb_channels * sub_sampling * i + ch]; } -- cgit v1.2.3 From d42aaa802e2b74dcb83d426001557f8229b1b484 Mon Sep 17 00:00:00 2001 From: Ronald Bultje Date: Mon, 20 Jun 2011 15:07:55 +0000 Subject: error_resilience: actually add counter when adding a MV predictor. Without, the predictor isn't actually used. --- libavcodec/error_resilience.c | 1 + tests/ref/vsynth1/error | 4 ++-- tests/ref/vsynth2/error | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index aea0e15b34..ad7a7c6ac6 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -547,6 +547,7 @@ skip_mean_and_median: mv_predictor[pred_count][0]= prev_x; mv_predictor[pred_count][1]= prev_y; ref [pred_count] = prev_ref; + pred_count++; s->mv_dir = MV_DIR_FORWARD; s->mb_intra=0; diff --git a/tests/ref/vsynth1/error b/tests/ref/vsynth1/error index 7edef21c90..bc24d5b2af 100644 --- a/tests/ref/vsynth1/error +++ b/tests/ref/vsynth1/error @@ -1,4 +1,4 @@ 7416dfd319f04044d4575dc9d1b406e1 *./tests/data/vsynth1/error-mpeg4-adv.avi 756836 ./tests/data/vsynth1/error-mpeg4-adv.avi -54342963593ba08bcde95244a011efe5 *./tests/data/error.vsynth1.out.yuv -stddev: 17.59 PSNR: 23.22 MAXDIFF: 240 bytes: 7603200/ 7603200 +79e94ba32b37759397362cbcb479d4d3 *./tests/data/error.vsynth1.out.yuv +stddev: 18.36 PSNR: 22.85 MAXDIFF: 243 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/error b/tests/ref/vsynth2/error index 99363f5a42..424c54962b 100644 --- a/tests/ref/vsynth2/error +++ b/tests/ref/vsynth2/error @@ -1,4 +1,4 @@ 90e65096aa9ebafa3fe3f44a5a47cdc4 *./tests/data/vsynth2/error-mpeg4-adv.avi 176588 ./tests/data/vsynth2/error-mpeg4-adv.avi -ce12aa852126f2740838dd2da9e21a03 *./tests/data/error.vsynth2.out.yuv -stddev: 10.06 PSNR: 28.08 MAXDIFF: 193 bytes: 7603200/ 7603200 +96baa9e4c24c837a3ba5abd8dd2cdd30 *./tests/data/error.vsynth2.out.yuv +stddev: 8.98 PSNR: 29.06 MAXDIFF: 184 bytes: 7603200/ 7603200 -- cgit v1.2.3 From 20153fb8f6ce7f482298170d2700befe898fa1cd Mon Sep 17 00:00:00 2001 From: Ronald Bultje Date: Mon, 20 Jun 2011 15:07:56 +0000 Subject: error_resilience: skip last-MV predictor step if MVs are not available. Fixes crashes when playing broken MPEG2-TS streams. --- libavcodec/error_resilience.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index ad7a7c6ac6..8906b49c80 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -534,6 +534,9 @@ skip_mean_and_median: ff_thread_await_progress((AVFrame *) s->last_picture_ptr, mb_y, 0); } + if (!s->last_picture.motion_val[0] || + !s->last_picture.ref_index[0]) + goto skip_last_mv; prev_x = s->last_picture.motion_val[0][mot_index][0]; prev_y = s->last_picture.motion_val[0][mot_index][1]; prev_ref = s->last_picture.ref_index[0][4*mb_xy]; @@ -548,6 +551,7 @@ skip_mean_and_median: mv_predictor[pred_count][1]= prev_y; ref [pred_count] = prev_ref; pred_count++; + skip_last_mv: s->mv_dir = MV_DIR_FORWARD; s->mb_intra=0; -- cgit v1.2.3 From dea22a1a912d5e6214db5c6a4addbc7b26881817 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 20 Jun 2011 22:40:31 +0200 Subject: document libswscale bump --- Changelog | 1 + doc/APIchanges | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index a5044498a5..b785197083 100644 --- a/Changelog +++ b/Changelog @@ -11,6 +11,7 @@ version 0.7: - All av_metadata_* functions renamed to av_dict_* and moved to libavutil - 4:4:4 H.264 decoding support - 10-bit H.264 optimizations for x86 +- Bump libswscale for recently reported ABI break version 0.7_beta2: diff --git a/doc/APIchanges b/doc/APIchanges index 460e8dde83..79d9749373 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -7,7 +7,7 @@ libavdevice: 2011-04-18 libavfilter: 2011-04-18 libavformat: 2011-04-18 libpostproc: 2011-04-18 -libswscale: 2011-04-18 +libswscale: 2011-06-20 libavutil: 2011-04-18 -- cgit v1.2.3 From eaa2d5a90a208fff0662b62da67b7b090b9fff8c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 00:59:35 +0100 Subject: cabac: remove #if 0 cascade under never-set #ifdef ARCH_X86_DISABLED Signed-off-by: Mans Rullgard --- libavcodec/cabac.h | 62 ------------------------------------------------------ 1 file changed, 62 deletions(-) diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index 4708563904..53e327d661 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -36,7 +36,6 @@ #define CABAC_BITS 16 #define CABAC_MASK ((1<63 for x86-64 - "shl %%cl, %0 \n\t" - "shl %%cl, %1 \n\t" - : "+r"(c->range), "+r"(c->low), "+c"(temp) - ); -#elif 0 - //P3:680 athlon:474 - __asm__( - "cmp $0x100, %0 \n\t" - "setb %%cl \n\t" //FIXME 31->63 for x86-64 - "shl %%cl, %0 \n\t" - "shl %%cl, %1 \n\t" - : "+r"(c->range), "+r"(c->low), "+c"(temp) - ); -#elif 1 - int temp2; - //P3:665 athlon:517 - __asm__( - "lea -0x100(%0), %%eax \n\t" - "cltd \n\t" - "mov %0, %%eax \n\t" - "and %%edx, %0 \n\t" - "and %1, %%edx \n\t" - "add %%eax, %0 \n\t" - "add %%edx, %1 \n\t" - : "+r"(c->range), "+r"(c->low), "+a"(temp), "+d"(temp2) - ); -#elif 0 - int temp2; - //P3:673 athlon:509 - __asm__( - "cmp $0x100, %0 \n\t" - "sbb %%edx, %%edx \n\t" - "mov %0, %%eax \n\t" - "and %%edx, %0 \n\t" - "and %1, %%edx \n\t" - "add %%eax, %0 \n\t" - "add %%edx, %1 \n\t" - : "+r"(c->range), "+r"(c->low), "+a"(temp), "+d"(temp2) - ); -#else - int temp2; - //P3:677 athlon:511 - __asm__( - "cmp $0x100, %0 \n\t" - "lea (%0, %0), %%eax \n\t" - "lea (%1, %1), %%edx \n\t" - "cmovb %%eax, %0 \n\t" - "cmovb %%edx, %1 \n\t" - : "+r"(c->range), "+r"(c->low), "+a"(temp), "+d"(temp2) - ); -#endif -#else - //P3:675 athlon:476 int shift= (uint32_t)(c->range - 0x100)>>31; c->range<<= shift; c->low <<= shift; -#endif if(!(c->low & CABAC_MASK)) refill(c); } -- cgit v1.2.3 From 8fcc0e7978e03cbf7e6d872d34ca1ea4a7d97b87 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 01:49:38 +0100 Subject: cabac: remove BRANCHLESS_CABAC_DECODER switch The code does not compile without this set. Signed-off-by: Mans Rullgard --- libavcodec/cabac.c | 8 ---- libavcodec/cabac.h | 106 +---------------------------------------------------- 2 files changed, 1 insertion(+), 113 deletions(-) diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index 098cd6fad9..691beb0ae3 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -161,19 +161,11 @@ void ff_init_cabac_states(CABACContext *c){ ff_h264_mps_state[2*i+1]= 2*mps_state[i]+1; if( i ){ -#ifdef BRANCHLESS_CABAC_DECODER ff_h264_mlps_state[128-2*i-1]= 2*lps_state[i]+0; ff_h264_mlps_state[128-2*i-2]= 2*lps_state[i]+1; }else{ ff_h264_mlps_state[128-2*i-1]= 1; ff_h264_mlps_state[128-2*i-2]= 0; -#else - ff_h264_lps_state[2*i+0]= 2*lps_state[i]+0; - ff_h264_lps_state[2*i+1]= 2*lps_state[i]+1; - }else{ - ff_h264_lps_state[2*i+0]= 1; - ff_h264_lps_state[2*i+1]= 0; -#endif } } } diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index 53e327d661..6b7ef4501c 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -35,7 +35,6 @@ #define CABAC_BITS 16 #define CABAC_MASK ((1<range&0xC0) + s]; - int bit, lps_mask av_unused; + int bit, lps_mask; c->range -= RangeLPS; -#ifndef BRANCHLESS_CABAC_DECODER - if(c->low < (c->range<<(CABAC_BITS+1))){ - bit= s&1; - *state= ff_h264_mps_state[s]; - renorm_cabac_decoder_once(c); - }else{ - bit= ff_h264_norm_shift[RangeLPS]; - c->low -= (c->range<<(CABAC_BITS+1)); - *state= ff_h264_lps_state[s]; - c->range = RangeLPS<low <<= bit; - bit= (s&1)^1; - - if(!(c->low & CABAC_MASK)){ - refill2(c); - } - } -#else /* BRANCHLESS_CABAC_DECODER */ lps_mask= ((c->range<<(CABAC_BITS+1)) - c->low)>>31; c->low -= (c->range<<(CABAC_BITS+1)) & lps_mask; @@ -513,7 +410,6 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st c->low <<= lps_mask; if(!(c->low & CABAC_MASK)) refill2(c); -#endif /* BRANCHLESS_CABAC_DECODER */ #endif /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) */ return bit; } -- cgit v1.2.3 From 34ee43fc0fa7f40a280f4f93a3c6aa5bf7a2704b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 01:58:36 +0100 Subject: cabac: remove inline asm under #if 0 A comment says it's not faster than the C code. Signed-off-by: Mans Rullgard --- libavcodec/cabac.h | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index 6b7ef4501c..0993eb80b3 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -423,36 +423,6 @@ static int av_unused get_cabac(CABACContext *c, uint8_t * const state){ } static int av_unused get_cabac_bypass(CABACContext *c){ -#if 0 //not faster - int bit; - __asm__ volatile( - "movl "RANGE "(%1), %%ebx \n\t" - "movl "LOW "(%1), %%eax \n\t" - "shl $17, %%ebx \n\t" - "add %%eax, %%eax \n\t" - "sub %%ebx, %%eax \n\t" - "cltd \n\t" - "and %%edx, %%ebx \n\t" - "add %%ebx, %%eax \n\t" - "test %%ax, %%ax \n\t" - " jnz 1f \n\t" - "movl "BYTE "(%1), %%"REG_b" \n\t" - "subl $0xFFFF, %%eax \n\t" - "movzwl (%%"REG_b"), %%ecx \n\t" - "bswap %%ecx \n\t" - "shrl $15, %%ecx \n\t" - "addl $2, %%"REG_b" \n\t" - "addl %%ecx, %%eax \n\t" - "movl %%"REG_b", "BYTE "(%1) \n\t" - "1: \n\t" - "movl %%eax, "LOW "(%1) \n\t" - - :"=&d"(bit) - :"r"(c) - : "%eax", "%"REG_b, "%ecx", "memory" - ); - return bit+1; -#else int range; c->low += c->low; @@ -466,7 +436,6 @@ static int av_unused get_cabac_bypass(CABACContext *c){ c->low -= range; return 1; } -#endif } -- cgit v1.2.3 From 6b712acc0e4face7e913fbffd03123fc24672654 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 01:54:32 +0100 Subject: x86: cabac: remove hardcoded struct offsets from inline asm Signed-off-by: Mans Rullgard --- libavcodec/cabac.h | 47 +++++++++++++++++++++------------------------- libavcodec/x86/h264_i386.h | 34 +++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index 0993eb80b3..67a332eba8 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -27,6 +27,8 @@ #ifndef AVCODEC_CABAC_H #define AVCODEC_CABAC_H +#include + #include "put_bits.h" //#undef NDEBUG @@ -307,17 +309,6 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ //FIXME gcc generates duplicate load/stores for c->low and c->range -#define LOW "0" -#define RANGE "4" -#if ARCH_X86_64 -#define BYTESTART "16" -#define BYTE "24" -#define BYTEEND "32" -#else -#define BYTESTART "12" -#define BYTE "16" -#define BYTEEND "20" -#endif #if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) int bit; @@ -347,7 +338,7 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st #endif /* HAVE_FAST_CMOV */ -#define BRANCHLESS_GET_CABAC(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ +#define BRANCHLESS_GET_CABAC(ret, cabac, statep, low, lowword, range, tmp, tmpbyte, byte) \ "movzbl "statep" , "ret" \n\t"\ "mov "range" , "tmp" \n\t"\ "and $0xC0 , "range" \n\t"\ @@ -361,13 +352,13 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st "shl %%cl , "low" \n\t"\ "test "lowword" , "lowword" \n\t"\ " jnz 1f \n\t"\ - "mov "BYTE"("cabac"), %%"REG_c" \n\t"\ + "mov "byte"("cabac"), %%"REG_c" \n\t"\ "movzwl (%%"REG_c") , "tmp" \n\t"\ "bswap "tmp" \n\t"\ "shr $15 , "tmp" \n\t"\ "sub $0xFFFF , "tmp" \n\t"\ "add $2 , %%"REG_c" \n\t"\ - "mov %%"REG_c" , "BYTE "("cabac") \n\t"\ + "mov %%"REG_c" , "byte "("cabac") \n\t"\ "lea -1("low") , %%ecx \n\t"\ "xor "low" , %%ecx \n\t"\ "shr $15 , %%ecx \n\t"\ @@ -379,14 +370,16 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st "1: \n\t" __asm__ volatile( - "movl "RANGE "(%2), %%esi \n\t" - "movl "LOW "(%2), %%ebx \n\t" - BRANCHLESS_GET_CABAC("%0", "%2", "(%1)", "%%ebx", "%%bx", "%%esi", "%%edx", "%%dl") - "movl %%esi, "RANGE "(%2) \n\t" - "movl %%ebx, "LOW "(%2) \n\t" + "movl %a3(%2), %%esi \n\t" + "movl %a4(%2), %%ebx \n\t" + BRANCHLESS_GET_CABAC("%0", "%2", "(%1)", "%%ebx", "%%bx", "%%esi", "%%edx", "%%dl", "%a5") + "movl %%esi, %a3(%2) \n\t" + "movl %%ebx, %a4(%2) \n\t" :"=&a"(bit) - :"r"(state), "r"(c) + :"r"(state), "r"(c), + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), + "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "%ebx", "%edx", "%esi", "memory" ); bit&=1; @@ -442,8 +435,8 @@ static int av_unused get_cabac_bypass(CABACContext *c){ static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ #if ARCH_X86 && HAVE_EBX_AVAILABLE __asm__ volatile( - "movl "RANGE "(%1), %%ebx \n\t" - "movl "LOW "(%1), %%eax \n\t" + "movl %a2(%1), %%ebx \n\t" + "movl %a3(%1), %%eax \n\t" "shl $17, %%ebx \n\t" "add %%eax, %%eax \n\t" "sub %%ebx, %%eax \n\t" @@ -454,19 +447,21 @@ static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ "sub %%edx, %%ecx \n\t" "test %%ax, %%ax \n\t" " jnz 1f \n\t" - "mov "BYTE "(%1), %%"REG_b" \n\t" + "mov %a4(%1), %%"REG_b" \n\t" "subl $0xFFFF, %%eax \n\t" "movzwl (%%"REG_b"), %%edx \n\t" "bswap %%edx \n\t" "shrl $15, %%edx \n\t" "add $2, %%"REG_b" \n\t" "addl %%edx, %%eax \n\t" - "mov %%"REG_b", "BYTE "(%1) \n\t" + "mov %%"REG_b", %a4(%1) \n\t" "1: \n\t" - "movl %%eax, "LOW "(%1) \n\t" + "movl %%eax, %a3(%1) \n\t" :"+c"(val) - :"r"(c) + :"r"(c), + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), + "i"(offsetof(CABACContext, bytestream)) : "%eax", "%"REG_b, "%edx", "memory" ); return val; diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index e2dffe1e46..b6c225a2f1 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -29,6 +29,8 @@ #ifndef AVCODEC_X86_H264_I386_H #define AVCODEC_X86_H264_I386_H +#include + #include "libavcodec/cabac.h" //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet @@ -42,20 +44,20 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, int minusindex= 4-(int)index; int coeff_count; __asm__ volatile( - "movl "RANGE "(%3), %%esi \n\t" - "movl "LOW "(%3), %%ebx \n\t" + "movl %a8(%3), %%esi \n\t" + "movl %a9(%3), %%ebx \n\t" "2: \n\t" BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx", - "%%bx", "%%esi", "%%eax", "%%al") + "%%bx", "%%esi", "%%eax", "%%al", "%a10") "test $1, %%edx \n\t" " jz 3f \n\t" "add %7, %1 \n\t" BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx", - "%%bx", "%%esi", "%%eax", "%%al") + "%%bx", "%%esi", "%%eax", "%%al", "%a10") "sub %7, %1 \n\t" "mov %2, %%"REG_a" \n\t" @@ -81,10 +83,12 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "add %6, %%eax \n\t" "shr $2, %%eax \n\t" - "movl %%esi, "RANGE "(%3) \n\t" - "movl %%ebx, "LOW "(%3) \n\t" + "movl %%esi, %a8(%3) \n\t" + "movl %%ebx, %a9(%3) \n\t" :"=&a"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index) - :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off) + :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), + "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "%ebx", "%edx", "%esi", "memory" ); return coeff_count; @@ -97,8 +101,8 @@ static int decode_significance_8x8_x86(CABACContext *c, int coeff_count; x86_reg last=0; __asm__ volatile( - "movl "RANGE "(%3), %%esi \n\t" - "movl "LOW "(%3), %%ebx \n\t" + "movl %a8(%3), %%esi \n\t" + "movl %a9(%3), %%ebx \n\t" "mov %1, %%"REG_D" \n\t" "2: \n\t" @@ -108,7 +112,7 @@ static int decode_significance_8x8_x86(CABACContext *c, "add %5, %%"REG_D" \n\t" BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx", - "%%bx", "%%esi", "%%eax", "%%al") + "%%bx", "%%esi", "%%eax", "%%al", "%a10") "mov %1, %%edi \n\t" "test $1, %%edx \n\t" @@ -119,7 +123,7 @@ static int decode_significance_8x8_x86(CABACContext *c, "add %7, %%"REG_D" \n\t" BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx", - "%%bx", "%%esi", "%%eax", "%%al") + "%%bx", "%%esi", "%%eax", "%%al", "%a10") "mov %2, %%"REG_a" \n\t" "mov %1, %%edi \n\t" @@ -142,10 +146,12 @@ static int decode_significance_8x8_x86(CABACContext *c, "addl %4, %%eax \n\t" "shr $2, %%eax \n\t" - "movl %%esi, "RANGE "(%3) \n\t" - "movl %%ebx, "LOW "(%3) \n\t" + "movl %%esi, %a8(%3) \n\t" + "movl %%ebx, %a9(%3) \n\t" :"=&a"(coeff_count),"+m"(last), "+m"(index) - :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off) + :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off), + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), + "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "%ebx", "%edx", "%esi", "%"REG_D, "memory" ); return coeff_count; -- cgit v1.2.3 From 018c33838eeb41944af46287e7d8be82c5c427d8 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 02:31:53 +0100 Subject: x86: cabac: remove hardcoded ebx in inline asm Signed-off-by: Mans Rullgard --- libavcodec/cabac.h | 53 ++++++++++++++++++----------------- libavcodec/x86/h264_i386.h | 70 ++++++++++++++++++++++++---------------------- 2 files changed, 63 insertions(+), 60 deletions(-) diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index 67a332eba8..b868f77f78 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -270,7 +270,7 @@ static void refill(CABACContext *c){ c->bytestream+= CABAC_BITS/8; } -#if ! ( ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) ) +#if ! ( ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) ) static void refill2(CABACContext *c){ int i, x; @@ -309,8 +309,8 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ //FIXME gcc generates duplicate load/stores for c->low and c->range -#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) - int bit; +#if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) + int bit, low; #if HAVE_FAST_CMOV #define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ @@ -370,20 +370,20 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st "1: \n\t" __asm__ volatile( - "movl %a3(%2), %%esi \n\t" - "movl %a4(%2), %%ebx \n\t" - BRANCHLESS_GET_CABAC("%0", "%2", "(%1)", "%%ebx", "%%bx", "%%esi", "%%edx", "%%dl", "%a5") - "movl %%esi, %a3(%2) \n\t" - "movl %%ebx, %a4(%2) \n\t" + "movl %a4(%3), %%esi \n\t" + "movl %a5(%3), %1 \n\t" + BRANCHLESS_GET_CABAC("%0", "%3", "(%2)", "%1", "%w1", "%%esi", "%%edx", "%%dl", "%a6") + "movl %%esi, %a4(%3) \n\t" + "movl %1, %a5(%3) \n\t" - :"=&a"(bit) + :"=&a"(bit), "=&r"(low) :"r"(state), "r"(c), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%ebx", "%edx", "%esi", "memory" + : "%"REG_c, "%edx", "%esi", "memory" ); bit&=1; -#else /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) */ +#else /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ int s = *state; int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + s]; int bit, lps_mask; @@ -403,7 +403,7 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st c->low <<= lps_mask; if(!(c->low & CABAC_MASK)) refill2(c); -#endif /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) */ +#endif /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ return bit; } @@ -433,36 +433,37 @@ static int av_unused get_cabac_bypass(CABACContext *c){ static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ -#if ARCH_X86 && HAVE_EBX_AVAILABLE +#if ARCH_X86 + x86_reg tmp; __asm__ volatile( - "movl %a2(%1), %%ebx \n\t" - "movl %a3(%1), %%eax \n\t" - "shl $17, %%ebx \n\t" + "movl %a3(%2), %k1 \n\t" + "movl %a4(%2), %%eax \n\t" + "shl $17, %k1 \n\t" "add %%eax, %%eax \n\t" - "sub %%ebx, %%eax \n\t" + "sub %k1, %%eax \n\t" "cltd \n\t" - "and %%edx, %%ebx \n\t" - "add %%ebx, %%eax \n\t" + "and %%edx, %k1 \n\t" + "add %k1, %%eax \n\t" "xor %%edx, %%ecx \n\t" "sub %%edx, %%ecx \n\t" "test %%ax, %%ax \n\t" " jnz 1f \n\t" - "mov %a4(%1), %%"REG_b" \n\t" + "mov %a5(%2), %1 \n\t" "subl $0xFFFF, %%eax \n\t" - "movzwl (%%"REG_b"), %%edx \n\t" + "movzwl (%1), %%edx \n\t" "bswap %%edx \n\t" "shrl $15, %%edx \n\t" - "add $2, %%"REG_b" \n\t" + "add $2, %1 \n\t" "addl %%edx, %%eax \n\t" - "mov %%"REG_b", %a4(%1) \n\t" + "mov %1, %a5(%2) \n\t" "1: \n\t" - "movl %%eax, %a3(%1) \n\t" + "movl %%eax, %a4(%2) \n\t" - :"+c"(val) + :"+c"(val), "=&r"(tmp) :"r"(c), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%eax", "%"REG_b, "%edx", "memory" + : "%eax", "%edx", "memory" ); return val; #else diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index b6c225a2f1..ba3a5ddfad 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -35,7 +35,7 @@ //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet //as that would make optimization work hard) -#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) +#if ARCH_X86 && HAVE_7REGS && !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){ @@ -43,25 +43,26 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, int minusstart= -(int)significant_coeff_ctx_base; int minusindex= 4-(int)index; int coeff_count; + int low; __asm__ volatile( - "movl %a8(%3), %%esi \n\t" - "movl %a9(%3), %%ebx \n\t" + "movl %a9(%4), %%esi \n\t" + "movl %a10(%4), %3 \n\t" "2: \n\t" - BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx", - "%%bx", "%%esi", "%%eax", "%%al", "%a10") + BRANCHLESS_GET_CABAC("%%edx", "%4", "(%1)", "%3", + "%w3", "%%esi", "%%eax", "%%al", "%a11") "test $1, %%edx \n\t" " jz 3f \n\t" - "add %7, %1 \n\t" + "add %8, %1 \n\t" - BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx", - "%%bx", "%%esi", "%%eax", "%%al", "%a10") + BRANCHLESS_GET_CABAC("%%edx", "%4", "(%1)", "%3", + "%w3", "%%esi", "%%eax", "%%al", "%a11") - "sub %7, %1 \n\t" + "sub %8, %1 \n\t" "mov %2, %%"REG_a" \n\t" - "movl %4, %%ecx \n\t" + "movl %5, %%ecx \n\t" "add %1, %%"REG_c" \n\t" "movl %%ecx, (%%"REG_a") \n\t" @@ -73,23 +74,24 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "3: \n\t" "add $1, %1 \n\t" - "cmp %5, %1 \n\t" + "cmp %6, %1 \n\t" " jb 2b \n\t" "mov %2, %%"REG_a" \n\t" - "movl %4, %%ecx \n\t" + "movl %5, %%ecx \n\t" "add %1, %%"REG_c" \n\t" "movl %%ecx, (%%"REG_a") \n\t" "4: \n\t" - "add %6, %%eax \n\t" + "add %7, %%eax \n\t" "shr $2, %%eax \n\t" - "movl %%esi, %a8(%3) \n\t" - "movl %%ebx, %a9(%3) \n\t" - :"=&a"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index) + "movl %%esi, %a9(%4) \n\t" + "movl %3, %a10(%4) \n\t" + :"=&a"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), + "=&r"(low) :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%ebx", "%edx", "%esi", "memory" + : "%"REG_c, "%edx", "%esi", "memory" ); return coeff_count; } @@ -99,31 +101,32 @@ static int decode_significance_8x8_x86(CABACContext *c, int *index, x86_reg last_off, const uint8_t *sig_off){ int minusindex= 4-(int)index; int coeff_count; + int low; x86_reg last=0; __asm__ volatile( - "movl %a8(%3), %%esi \n\t" - "movl %a9(%3), %%ebx \n\t" + "movl %a9(%4), %%esi \n\t" + "movl %a10(%4), %3 \n\t" "mov %1, %%"REG_D" \n\t" "2: \n\t" - "mov %6, %%"REG_a" \n\t" + "mov %7, %%"REG_a" \n\t" "movzbl (%%"REG_a", %%"REG_D"), %%edi \n\t" - "add %5, %%"REG_D" \n\t" + "add %6, %%"REG_D" \n\t" - BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx", - "%%bx", "%%esi", "%%eax", "%%al", "%a10") + BRANCHLESS_GET_CABAC("%%edx", "%4", "(%%"REG_D")", "%3", + "%w3", "%%esi", "%%eax", "%%al", "%a11") "mov %1, %%edi \n\t" "test $1, %%edx \n\t" " jz 3f \n\t" "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%%edi), %%edi\n\t" - "add %5, %%"REG_D" \n\t" - "add %7, %%"REG_D" \n\t" + "add %6, %%"REG_D" \n\t" + "add %8, %%"REG_D" \n\t" - BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx", - "%%bx", "%%esi", "%%eax", "%%al", "%a10") + BRANCHLESS_GET_CABAC("%%edx", "%4", "(%%"REG_D")", "%3", + "%w3", "%%esi", "%%eax", "%%al", "%a11") "mov %2, %%"REG_a" \n\t" "mov %1, %%edi \n\t" @@ -143,20 +146,19 @@ static int decode_significance_8x8_x86(CABACContext *c, "mov %2, %%"REG_a" \n\t" "movl %%edi, (%%"REG_a") \n\t" "4: \n\t" - "addl %4, %%eax \n\t" + "addl %5, %%eax \n\t" "shr $2, %%eax \n\t" - "movl %%esi, %a8(%3) \n\t" - "movl %%ebx, %a9(%3) \n\t" - :"=&a"(coeff_count),"+m"(last), "+m"(index) + "movl %%esi, %a9(%4) \n\t" + "movl %3, %a10(%4) \n\t" + :"=&a"(coeff_count),"+m"(last), "+m"(index), "=&r"(low) :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%ebx", "%edx", "%esi", "%"REG_D, "memory" + : "%"REG_c, "%edx", "%esi", "%"REG_D, "memory" ); return coeff_count; } -#endif /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE */ - /* !defined(BROKEN_RELOCATIONS) */ +#endif /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ #endif /* AVCODEC_X86_H264_I386_H */ -- cgit v1.2.3 From 51f16a9bf22ee81116df2a02d3107c6f3ad17402 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 03:19:20 +0100 Subject: x86: cabac: remove unused macro parameter Signed-off-by: Mans Rullgard --- libavcodec/cabac.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index b868f77f78..c80c259614 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -313,7 +313,7 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st int bit, low; #if HAVE_FAST_CMOV -#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ +#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ "mov "tmp" , %%ecx \n\t"\ "shl $17 , "tmp" \n\t"\ "cmp "low" , "tmp" \n\t"\ @@ -323,7 +323,7 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st "sub "tmp" , "low" \n\t"\ "xor %%ecx , "ret" \n\t" #else /* HAVE_FAST_CMOV */ -#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ +#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ "mov "tmp" , %%ecx \n\t"\ "shl $17 , "tmp" \n\t"\ "sub "low" , "tmp" \n\t"\ @@ -344,7 +344,7 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st "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, tmpbyte)\ + BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, 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"\ -- cgit v1.2.3 From da3af4db6151775a851c181c8aba802db07ce033 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 03:39:45 +0100 Subject: x86: cabac: remove hardcoded edx in get_cabac_inline() Signed-off-by: Mans Rullgard --- libavcodec/cabac.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index c80c259614..f2b07d6886 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -310,7 +310,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ //FIXME gcc generates duplicate load/stores for c->low and c->range #if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) - int bit, low; + int bit, low, tmp; #if HAVE_FAST_CMOV #define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ @@ -370,17 +370,17 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st "1: \n\t" __asm__ volatile( - "movl %a4(%3), %%esi \n\t" - "movl %a5(%3), %1 \n\t" - BRANCHLESS_GET_CABAC("%0", "%3", "(%2)", "%1", "%w1", "%%esi", "%%edx", "%%dl", "%a6") - "movl %%esi, %a4(%3) \n\t" - "movl %1, %a5(%3) \n\t" + "movl %a5(%4), %%esi \n\t" + "movl %a6(%4), %1 \n\t" + BRANCHLESS_GET_CABAC("%0", "%4", "(%3)", "%1", "%w1", "%%esi", "%2", "%b2", "%a7") + "movl %%esi, %a5(%4) \n\t" + "movl %1, %a6(%4) \n\t" - :"=&a"(bit), "=&r"(low) + :"=&a"(bit), "=&r"(low), "=&r"(tmp) :"r"(state), "r"(c), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%edx", "%esi", "memory" + : "%"REG_c, "%esi", "memory" ); bit&=1; #else /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ -- cgit v1.2.3 From f743595e87aecc090cf6884fc681c0adf3a03cbb Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 09:19:27 +0100 Subject: x86: cabac: remove hardcoded esi in get_cabac_inline() Signed-off-by: Mans Rullgard --- libavcodec/cabac.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index f2b07d6886..b967da5ab6 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -310,7 +310,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ //FIXME gcc generates duplicate load/stores for c->low and c->range #if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) - int bit, low, tmp; + int bit, low, range, tmp; #if HAVE_FAST_CMOV #define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ @@ -370,17 +370,17 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st "1: \n\t" __asm__ volatile( - "movl %a5(%4), %%esi \n\t" - "movl %a6(%4), %1 \n\t" - BRANCHLESS_GET_CABAC("%0", "%4", "(%3)", "%1", "%w1", "%%esi", "%2", "%b2", "%a7") - "movl %%esi, %a5(%4) \n\t" - "movl %1, %a6(%4) \n\t" + "movl %a6(%5), %2 \n\t" + "movl %a7(%5), %1 \n\t" + BRANCHLESS_GET_CABAC("%0", "%5", "(%4)", "%1", "%w1", "%2", "%3", "%b3", "%a8") + "movl %2, %a6(%5) \n\t" + "movl %1, %a7(%5) \n\t" - :"=&a"(bit), "=&r"(low), "=&r"(tmp) + :"=&a"(bit), "=&r"(low), "=&r"(range), "=&r"(tmp) :"r"(state), "r"(c), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%esi", "memory" + : "%"REG_c, "memory" ); bit&=1; #else /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ -- cgit v1.2.3 From 3146a30e612729e4a70dd10361c8a38750fa6d53 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 09:28:19 +0100 Subject: x86: cabac: change 'a' constraint to 'r' in get_cabac_inline() Nothing requires this value in %eax. Signed-off-by: Mans Rullgard --- libavcodec/cabac.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index b967da5ab6..adccf54aab 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -376,7 +376,7 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st "movl %2, %a6(%5) \n\t" "movl %1, %a7(%5) \n\t" - :"=&a"(bit), "=&r"(low), "=&r"(range), "=&r"(tmp) + :"=&r"(bit), "=&r"(low), "=&r"(range), "=&r"(tmp) :"r"(state), "r"(c), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) -- cgit v1.2.3 From e4b5a204aa2269cc249771fd49a89e7b4af32215 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 09:23:26 +0100 Subject: x86: h264: remove hardcoded eax in decode_significance[_8x8]_x86() Signed-off-by: Mans Rullgard --- libavcodec/x86/h264_i386.h | 52 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index ba3a5ddfad..a0dd7ea783 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -42,7 +42,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, void *end= significant_coeff_ctx_base + max_coeff - 1; int minusstart= -(int)significant_coeff_ctx_base; int minusindex= 4-(int)index; - int coeff_count; + x86_reg coeff_count; int low; __asm__ volatile( "movl %a9(%4), %%esi \n\t" @@ -51,42 +51,42 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "2: \n\t" BRANCHLESS_GET_CABAC("%%edx", "%4", "(%1)", "%3", - "%w3", "%%esi", "%%eax", "%%al", "%a11") + "%w3", "%%esi", "%k0", "%b0", "%a11") "test $1, %%edx \n\t" " jz 3f \n\t" "add %8, %1 \n\t" BRANCHLESS_GET_CABAC("%%edx", "%4", "(%1)", "%3", - "%w3", "%%esi", "%%eax", "%%al", "%a11") + "%w3", "%%esi", "%k0", "%b0", "%a11") "sub %8, %1 \n\t" - "mov %2, %%"REG_a" \n\t" + "mov %2, %0 \n\t" "movl %5, %%ecx \n\t" "add %1, %%"REG_c" \n\t" - "movl %%ecx, (%%"REG_a") \n\t" + "movl %%ecx, (%0) \n\t" "test $1, %%edx \n\t" " jnz 4f \n\t" - "add $4, %%"REG_a" \n\t" - "mov %%"REG_a", %2 \n\t" + "add $4, %0 \n\t" + "mov %0, %2 \n\t" "3: \n\t" "add $1, %1 \n\t" "cmp %6, %1 \n\t" " jb 2b \n\t" - "mov %2, %%"REG_a" \n\t" + "mov %2, %0 \n\t" "movl %5, %%ecx \n\t" "add %1, %%"REG_c" \n\t" - "movl %%ecx, (%%"REG_a") \n\t" + "movl %%ecx, (%0) \n\t" "4: \n\t" - "add %7, %%eax \n\t" - "shr $2, %%eax \n\t" + "add %7, %k0 \n\t" + "shr $2, %k0 \n\t" "movl %%esi, %a9(%4) \n\t" "movl %3, %a10(%4) \n\t" - :"=&a"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), + :"=&r"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), "=&r"(low) :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), @@ -100,7 +100,7 @@ static int decode_significance_8x8_x86(CABACContext *c, uint8_t *significant_coeff_ctx_base, int *index, x86_reg last_off, const uint8_t *sig_off){ int minusindex= 4-(int)index; - int coeff_count; + x86_reg coeff_count; int low; x86_reg last=0; __asm__ volatile( @@ -110,12 +110,12 @@ static int decode_significance_8x8_x86(CABACContext *c, "mov %1, %%"REG_D" \n\t" "2: \n\t" - "mov %7, %%"REG_a" \n\t" - "movzbl (%%"REG_a", %%"REG_D"), %%edi \n\t" + "mov %7, %0 \n\t" + "movzbl (%0, %%"REG_D"), %%edi \n\t" "add %6, %%"REG_D" \n\t" BRANCHLESS_GET_CABAC("%%edx", "%4", "(%%"REG_D")", "%3", - "%w3", "%%esi", "%%eax", "%%al", "%a11") + "%w3", "%%esi", "%k0", "%b0", "%a11") "mov %1, %%edi \n\t" "test $1, %%edx \n\t" @@ -126,32 +126,32 @@ static int decode_significance_8x8_x86(CABACContext *c, "add %8, %%"REG_D" \n\t" BRANCHLESS_GET_CABAC("%%edx", "%4", "(%%"REG_D")", "%3", - "%w3", "%%esi", "%%eax", "%%al", "%a11") + "%w3", "%%esi", "%k0", "%b0", "%a11") - "mov %2, %%"REG_a" \n\t" + "mov %2, %0 \n\t" "mov %1, %%edi \n\t" - "movl %%edi, (%%"REG_a") \n\t" + "movl %%edi, (%0) \n\t" "test $1, %%edx \n\t" " jnz 4f \n\t" - "add $4, %%"REG_a" \n\t" - "mov %%"REG_a", %2 \n\t" + "add $4, %0 \n\t" + "mov %0, %2 \n\t" "3: \n\t" "addl $1, %%edi \n\t" "mov %%edi, %1 \n\t" "cmpl $63, %%edi \n\t" " jb 2b \n\t" - "mov %2, %%"REG_a" \n\t" - "movl %%edi, (%%"REG_a") \n\t" + "mov %2, %0 \n\t" + "movl %%edi, (%0) \n\t" "4: \n\t" - "addl %5, %%eax \n\t" - "shr $2, %%eax \n\t" + "addl %5, %k0 \n\t" + "shr $2, %k0 \n\t" "movl %%esi, %a9(%4) \n\t" "movl %3, %a10(%4) \n\t" - :"=&a"(coeff_count),"+m"(last), "+m"(index), "=&r"(low) + :"=&r"(coeff_count),"+m"(last), "+m"(index), "=&r"(low) :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) -- cgit v1.2.3 From 3fc4e36c78004b37b6179423231e3e0daa3c7e74 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 10:06:07 +0100 Subject: x86: h264: remove hardcoded edx in decode_significance[_8x8]_x86() Signed-off-by: Mans Rullgard --- libavcodec/x86/h264_i386.h | 72 ++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index a0dd7ea783..b303347c0f 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -42,31 +42,32 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, void *end= significant_coeff_ctx_base + max_coeff - 1; int minusstart= -(int)significant_coeff_ctx_base; int minusindex= 4-(int)index; + int bit; x86_reg coeff_count; int low; __asm__ volatile( - "movl %a9(%4), %%esi \n\t" - "movl %a10(%4), %3 \n\t" + "movl %a10(%5), %%esi \n\t" + "movl %a11(%5), %3 \n\t" "2: \n\t" - BRANCHLESS_GET_CABAC("%%edx", "%4", "(%1)", "%3", - "%w3", "%%esi", "%k0", "%b0", "%a11") + BRANCHLESS_GET_CABAC("%4", "%5", "(%1)", "%3", + "%w3", "%%esi", "%k0", "%b0", "%a12") - "test $1, %%edx \n\t" + "test $1, %4 \n\t" " jz 3f \n\t" - "add %8, %1 \n\t" + "add %9, %1 \n\t" - BRANCHLESS_GET_CABAC("%%edx", "%4", "(%1)", "%3", - "%w3", "%%esi", "%k0", "%b0", "%a11") + BRANCHLESS_GET_CABAC("%4", "%5", "(%1)", "%3", + "%w3", "%%esi", "%k0", "%b0", "%a12") - "sub %8, %1 \n\t" + "sub %9, %1 \n\t" "mov %2, %0 \n\t" - "movl %5, %%ecx \n\t" + "movl %6, %%ecx \n\t" "add %1, %%"REG_c" \n\t" "movl %%ecx, (%0) \n\t" - "test $1, %%edx \n\t" + "test $1, %4 \n\t" " jnz 4f \n\t" "add $4, %0 \n\t" @@ -74,24 +75,24 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "3: \n\t" "add $1, %1 \n\t" - "cmp %6, %1 \n\t" + "cmp %7, %1 \n\t" " jb 2b \n\t" "mov %2, %0 \n\t" - "movl %5, %%ecx \n\t" + "movl %6, %%ecx \n\t" "add %1, %%"REG_c" \n\t" "movl %%ecx, (%0) \n\t" "4: \n\t" - "add %7, %k0 \n\t" + "add %8, %k0 \n\t" "shr $2, %k0 \n\t" - "movl %%esi, %a9(%4) \n\t" - "movl %3, %a10(%4) \n\t" + "movl %%esi, %a10(%5) \n\t" + "movl %3, %a11(%5) \n\t" :"=&r"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), - "=&r"(low) + "=&r"(low), "=&r"(bit) :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%edx", "%esi", "memory" + : "%"REG_c, "%esi", "memory" ); return coeff_count; } @@ -100,39 +101,40 @@ static int decode_significance_8x8_x86(CABACContext *c, uint8_t *significant_coeff_ctx_base, int *index, x86_reg last_off, const uint8_t *sig_off){ int minusindex= 4-(int)index; + int bit; x86_reg coeff_count; int low; x86_reg last=0; __asm__ volatile( - "movl %a9(%4), %%esi \n\t" - "movl %a10(%4), %3 \n\t" + "movl %a10(%5), %%esi \n\t" + "movl %a11(%5), %3 \n\t" "mov %1, %%"REG_D" \n\t" "2: \n\t" - "mov %7, %0 \n\t" + "mov %8, %0 \n\t" "movzbl (%0, %%"REG_D"), %%edi \n\t" - "add %6, %%"REG_D" \n\t" + "add %7, %%"REG_D" \n\t" - BRANCHLESS_GET_CABAC("%%edx", "%4", "(%%"REG_D")", "%3", - "%w3", "%%esi", "%k0", "%b0", "%a11") + BRANCHLESS_GET_CABAC("%4", "%5", "(%%"REG_D")", "%3", + "%w3", "%%esi", "%k0", "%b0", "%a12") "mov %1, %%edi \n\t" - "test $1, %%edx \n\t" + "test $1, %4 \n\t" " jz 3f \n\t" "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%%edi), %%edi\n\t" - "add %6, %%"REG_D" \n\t" - "add %8, %%"REG_D" \n\t" + "add %7, %%"REG_D" \n\t" + "add %9, %%"REG_D" \n\t" - BRANCHLESS_GET_CABAC("%%edx", "%4", "(%%"REG_D")", "%3", - "%w3", "%%esi", "%k0", "%b0", "%a11") + BRANCHLESS_GET_CABAC("%4", "%5", "(%%"REG_D")", "%3", + "%w3", "%%esi", "%k0", "%b0", "%a12") "mov %2, %0 \n\t" "mov %1, %%edi \n\t" "movl %%edi, (%0) \n\t" - "test $1, %%edx \n\t" + "test $1, %4 \n\t" " jnz 4f \n\t" "add $4, %0 \n\t" @@ -146,16 +148,16 @@ static int decode_significance_8x8_x86(CABACContext *c, "mov %2, %0 \n\t" "movl %%edi, (%0) \n\t" "4: \n\t" - "addl %5, %k0 \n\t" + "addl %6, %k0 \n\t" "shr $2, %k0 \n\t" - "movl %%esi, %a9(%4) \n\t" - "movl %3, %a10(%4) \n\t" - :"=&r"(coeff_count),"+m"(last), "+m"(index), "=&r"(low) + "movl %%esi, %a10(%5) \n\t" + "movl %3, %a11(%5) \n\t" + :"=&r"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit) :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%edx", "%esi", "%"REG_D, "memory" + : "%"REG_c, "%esi", "%"REG_D, "memory" ); return coeff_count; } -- cgit v1.2.3 From b92c1a6d2630e46b6e7c6ceca467e7f56fae5218 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 10:12:29 +0100 Subject: x86: h264: remove hardcoded esi in decode_significance[_8x8]_x86() Signed-off-by: Mans Rullgard --- libavcodec/x86/h264_i386.h | 65 ++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index b303347c0f..d38b18e5e5 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -45,25 +45,26 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, int bit; x86_reg coeff_count; int low; + int range; __asm__ volatile( - "movl %a10(%5), %%esi \n\t" - "movl %a11(%5), %3 \n\t" + "movl %a11(%6), %5 \n\t" + "movl %a12(%6), %3 \n\t" "2: \n\t" - BRANCHLESS_GET_CABAC("%4", "%5", "(%1)", "%3", - "%w3", "%%esi", "%k0", "%b0", "%a12") + BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3", + "%w3", "%5", "%k0", "%b0", "%a13") "test $1, %4 \n\t" " jz 3f \n\t" - "add %9, %1 \n\t" + "add %10, %1 \n\t" - BRANCHLESS_GET_CABAC("%4", "%5", "(%1)", "%3", - "%w3", "%%esi", "%k0", "%b0", "%a12") + BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3", + "%w3", "%5", "%k0", "%b0", "%a13") - "sub %9, %1 \n\t" + "sub %10, %1 \n\t" "mov %2, %0 \n\t" - "movl %6, %%ecx \n\t" + "movl %7, %%ecx \n\t" "add %1, %%"REG_c" \n\t" "movl %%ecx, (%0) \n\t" @@ -75,24 +76,24 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "3: \n\t" "add $1, %1 \n\t" - "cmp %7, %1 \n\t" + "cmp %8, %1 \n\t" " jb 2b \n\t" "mov %2, %0 \n\t" - "movl %6, %%ecx \n\t" + "movl %7, %%ecx \n\t" "add %1, %%"REG_c" \n\t" "movl %%ecx, (%0) \n\t" "4: \n\t" - "add %8, %k0 \n\t" + "add %9, %k0 \n\t" "shr $2, %k0 \n\t" - "movl %%esi, %a10(%5) \n\t" - "movl %3, %a11(%5) \n\t" + "movl %5, %a11(%6) \n\t" + "movl %3, %a12(%6) \n\t" :"=&r"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), - "=&r"(low), "=&r"(bit) + "=&r"(low), "=&r"(bit), "=&r"(range) :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%esi", "memory" + : "%"REG_c, "memory" ); return coeff_count; } @@ -104,31 +105,32 @@ static int decode_significance_8x8_x86(CABACContext *c, int bit; x86_reg coeff_count; int low; + int range; x86_reg last=0; __asm__ volatile( - "movl %a10(%5), %%esi \n\t" - "movl %a11(%5), %3 \n\t" + "movl %a11(%6), %5 \n\t" + "movl %a12(%6), %3 \n\t" "mov %1, %%"REG_D" \n\t" "2: \n\t" - "mov %8, %0 \n\t" + "mov %9, %0 \n\t" "movzbl (%0, %%"REG_D"), %%edi \n\t" - "add %7, %%"REG_D" \n\t" + "add %8, %%"REG_D" \n\t" - BRANCHLESS_GET_CABAC("%4", "%5", "(%%"REG_D")", "%3", - "%w3", "%%esi", "%k0", "%b0", "%a12") + BRANCHLESS_GET_CABAC("%4", "%6", "(%%"REG_D")", "%3", + "%w3", "%5", "%k0", "%b0", "%a13") "mov %1, %%edi \n\t" "test $1, %4 \n\t" " jz 3f \n\t" "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%%edi), %%edi\n\t" - "add %7, %%"REG_D" \n\t" - "add %9, %%"REG_D" \n\t" + "add %8, %%"REG_D" \n\t" + "add %10, %%"REG_D" \n\t" - BRANCHLESS_GET_CABAC("%4", "%5", "(%%"REG_D")", "%3", - "%w3", "%%esi", "%k0", "%b0", "%a12") + BRANCHLESS_GET_CABAC("%4", "%6", "(%%"REG_D")", "%3", + "%w3", "%5", "%k0", "%b0", "%a13") "mov %2, %0 \n\t" "mov %1, %%edi \n\t" @@ -148,16 +150,17 @@ static int decode_significance_8x8_x86(CABACContext *c, "mov %2, %0 \n\t" "movl %%edi, (%0) \n\t" "4: \n\t" - "addl %6, %k0 \n\t" + "addl %7, %k0 \n\t" "shr $2, %k0 \n\t" - "movl %%esi, %a10(%5) \n\t" - "movl %3, %a11(%5) \n\t" - :"=&r"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit) + "movl %5, %a11(%6) \n\t" + "movl %3, %a12(%6) \n\t" + :"=&r"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit), + "=&r"(range) :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%esi", "%"REG_D, "memory" + : "%"REG_c, "%"REG_D, "memory" ); return coeff_count; } -- cgit v1.2.3 From 3a4edb76d697cfa341ee060647732e5c1400da3a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 10:20:15 +0100 Subject: x86: h264: remove hardcoded edi in decode_significance_8x8_x86() Signed-off-by: Mans Rullgard --- libavcodec/x86/h264_i386.h | 51 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index d38b18e5e5..1b55dd830f 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -107,34 +107,35 @@ static int decode_significance_8x8_x86(CABACContext *c, int low; int range; x86_reg last=0; + x86_reg state; __asm__ volatile( - "movl %a11(%6), %5 \n\t" - "movl %a12(%6), %3 \n\t" + "movl %a12(%7), %5 \n\t" + "movl %a13(%7), %3 \n\t" - "mov %1, %%"REG_D" \n\t" + "mov %1, %6 \n\t" "2: \n\t" - "mov %9, %0 \n\t" - "movzbl (%0, %%"REG_D"), %%edi \n\t" - "add %8, %%"REG_D" \n\t" + "mov %10, %0 \n\t" + "movzbl (%0, %6), %k6 \n\t" + "add %9, %6 \n\t" - BRANCHLESS_GET_CABAC("%4", "%6", "(%%"REG_D")", "%3", - "%w3", "%5", "%k0", "%b0", "%a13") + BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3", + "%w3", "%5", "%k0", "%b0", "%a14") - "mov %1, %%edi \n\t" + "mov %1, %k6 \n\t" "test $1, %4 \n\t" " jz 3f \n\t" - "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%%edi), %%edi\n\t" - "add %8, %%"REG_D" \n\t" - "add %10, %%"REG_D" \n\t" + "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t" + "add %9, %6 \n\t" + "add %11, %6 \n\t" - BRANCHLESS_GET_CABAC("%4", "%6", "(%%"REG_D")", "%3", - "%w3", "%5", "%k0", "%b0", "%a13") + BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3", + "%w3", "%5", "%k0", "%b0", "%a14") "mov %2, %0 \n\t" - "mov %1, %%edi \n\t" - "movl %%edi, (%0) \n\t" + "mov %1, %k6 \n\t" + "movl %k6, (%0) \n\t" "test $1, %4 \n\t" " jnz 4f \n\t" @@ -143,24 +144,24 @@ static int decode_significance_8x8_x86(CABACContext *c, "mov %0, %2 \n\t" "3: \n\t" - "addl $1, %%edi \n\t" - "mov %%edi, %1 \n\t" - "cmpl $63, %%edi \n\t" + "addl $1, %k6 \n\t" + "mov %k6, %1 \n\t" + "cmpl $63, %k6 \n\t" " jb 2b \n\t" "mov %2, %0 \n\t" - "movl %%edi, (%0) \n\t" + "movl %k6, (%0) \n\t" "4: \n\t" - "addl %7, %k0 \n\t" + "addl %8, %k0 \n\t" "shr $2, %k0 \n\t" - "movl %5, %a11(%6) \n\t" - "movl %3, %a12(%6) \n\t" + "movl %5, %a12(%7) \n\t" + "movl %3, %a13(%7) \n\t" :"=&r"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit), - "=&r"(range) + "=&r"(range), "=&r"(state) :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "%"REG_D, "memory" + : "%"REG_c, "memory" ); return coeff_count; } -- cgit v1.2.3 From d075e7d5405d716170476a2fea707dfe3330093c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 10:24:26 +0100 Subject: x86: h264: cast pointers to intptr_t rather than int Only the low-order bits are used here so the type is not important, but this avoids a compiler warning. Signed-off-by: Mans Rullgard --- libavcodec/x86/h264_i386.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 1b55dd830f..9f5e53105e 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -40,8 +40,8 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, uint8_t *significant_coeff_ctx_base, int *index, x86_reg last_off){ void *end= significant_coeff_ctx_base + max_coeff - 1; - int minusstart= -(int)significant_coeff_ctx_base; - int minusindex= 4-(int)index; + int minusstart= -(intptr_t)significant_coeff_ctx_base; + int minusindex= 4-(intptr_t)index; int bit; x86_reg coeff_count; int low; @@ -101,7 +101,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, static int decode_significance_8x8_x86(CABACContext *c, uint8_t *significant_coeff_ctx_base, int *index, x86_reg last_off, const uint8_t *sig_off){ - int minusindex= 4-(int)index; + int minusindex= 4-(intptr_t)index; int bit; x86_reg coeff_count; int low; -- cgit v1.2.3 From 2143d69bddf42c8c2cf9f45e1f0ce7750e96aad3 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 10:53:41 +0100 Subject: cabac: move x86 asm to libavcodec/x86/cabac.h Signed-off-by: Mans Rullgard --- libavcodec/cabac.h | 156 +++++++-------------------------------------- libavcodec/x86/cabac.h | 148 ++++++++++++++++++++++++++++++++++++++++++ libavcodec/x86/h264_i386.h | 1 + 3 files changed, 173 insertions(+), 132 deletions(-) create mode 100644 libavcodec/x86/cabac.h diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index adccf54aab..57d1d70d29 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -33,7 +33,6 @@ //#undef NDEBUG #include -#include "libavutil/x86_cpu.h" #define CABAC_BITS 16 #define CABAC_MASK ((1<bytestream+= CABAC_BITS/8; } -#if ! ( ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) ) +static inline void renorm_cabac_decoder(CABACContext *c){ + while(c->range < 0x100){ + c->range+= c->range; + c->low+= c->low; + if(!(c->low & CABAC_MASK)) + refill(c); + } +} + +static inline void renorm_cabac_decoder_once(CABACContext *c){ + int shift= (uint32_t)(c->range - 0x100)>>31; + c->range<<= shift; + c->low <<= shift; + if(!(c->low & CABAC_MASK)) + refill(c); +} + +#ifndef get_cabac_inline static void refill2(CABACContext *c){ int i, x; @@ -288,102 +307,8 @@ static void refill2(CABACContext *c){ c->low += x<bytestream+= CABAC_BITS/8; } -#endif - -static inline void renorm_cabac_decoder(CABACContext *c){ - while(c->range < 0x100){ - c->range+= c->range; - c->low+= c->low; - if(!(c->low & CABAC_MASK)) - refill(c); - } -} - -static inline void renorm_cabac_decoder_once(CABACContext *c){ - int shift= (uint32_t)(c->range - 0x100)>>31; - c->range<<= shift; - c->low <<= shift; - if(!(c->low & CABAC_MASK)) - refill(c); -} static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ - //FIXME gcc generates duplicate load/stores for c->low and c->range -#if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) - int bit, low, range, tmp; - -#if HAVE_FAST_CMOV -#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ - "mov "tmp" , %%ecx \n\t"\ - "shl $17 , "tmp" \n\t"\ - "cmp "low" , "tmp" \n\t"\ - "cmova %%ecx , "range" \n\t"\ - "sbb %%ecx , %%ecx \n\t"\ - "and %%ecx , "tmp" \n\t"\ - "sub "tmp" , "low" \n\t"\ - "xor %%ecx , "ret" \n\t" -#else /* HAVE_FAST_CMOV */ -#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ - "mov "tmp" , %%ecx \n\t"\ - "shl $17 , "tmp" \n\t"\ - "sub "low" , "tmp" \n\t"\ - "sar $31 , "tmp" \n\t" /*lps_mask*/\ - "sub %%ecx , "range" \n\t" /*RangeLPS - range*/\ - "and "tmp" , "range" \n\t" /*(RangeLPS - range)&lps_mask*/\ - "add %%ecx , "range" \n\t" /*new range*/\ - "shl $17 , %%ecx \n\t"\ - "and "tmp" , %%ecx \n\t"\ - "sub %%ecx , "low" \n\t"\ - "xor "tmp" , "ret" \n\t" -#endif /* HAVE_FAST_CMOV */ - - -#define BRANCHLESS_GET_CABAC(ret, cabac, 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)\ - "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"\ - "mov "tmpbyte" , "statep" \n\t"\ - "shl %%cl , "low" \n\t"\ - "test "lowword" , "lowword" \n\t"\ - " jnz 1f \n\t"\ - "mov "byte"("cabac"), %%"REG_c" \n\t"\ - "movzwl (%%"REG_c") , "tmp" \n\t"\ - "bswap "tmp" \n\t"\ - "shr $15 , "tmp" \n\t"\ - "sub $0xFFFF , "tmp" \n\t"\ - "add $2 , %%"REG_c" \n\t"\ - "mov %%"REG_c" , "byte "("cabac") \n\t"\ - "lea -1("low") , %%ecx \n\t"\ - "xor "low" , %%ecx \n\t"\ - "shr $15 , %%ecx \n\t"\ - "movzbl " MANGLE(ff_h264_norm_shift) "(%%ecx), %%ecx \n\t"\ - "neg %%ecx \n\t"\ - "add $7 , %%ecx \n\t"\ - "shl %%cl , "tmp" \n\t"\ - "add "tmp" , "low" \n\t"\ - "1: \n\t" - - __asm__ volatile( - "movl %a6(%5), %2 \n\t" - "movl %a7(%5), %1 \n\t" - BRANCHLESS_GET_CABAC("%0", "%5", "(%4)", "%1", "%w1", "%2", "%3", "%b3", "%a8") - "movl %2, %a6(%5) \n\t" - "movl %1, %a7(%5) \n\t" - - :"=&r"(bit), "=&r"(low), "=&r"(range), "=&r"(tmp) - :"r"(state), "r"(c), - "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), - "i"(offsetof(CABACContext, bytestream)) - : "%"REG_c, "memory" - ); - bit&=1; -#else /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ int s = *state; int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + s]; int bit, lps_mask; @@ -403,9 +328,9 @@ static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const st c->low <<= lps_mask; if(!(c->low & CABAC_MASK)) refill2(c); -#endif /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ return bit; } +#endif static int av_noinline av_unused get_cabac_noinline(CABACContext *c, uint8_t * const state){ return get_cabac_inline(c,state); @@ -432,41 +357,8 @@ static int av_unused get_cabac_bypass(CABACContext *c){ } +#ifndef get_cabac_bypass_sign static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ -#if ARCH_X86 - x86_reg tmp; - __asm__ volatile( - "movl %a3(%2), %k1 \n\t" - "movl %a4(%2), %%eax \n\t" - "shl $17, %k1 \n\t" - "add %%eax, %%eax \n\t" - "sub %k1, %%eax \n\t" - "cltd \n\t" - "and %%edx, %k1 \n\t" - "add %k1, %%eax \n\t" - "xor %%edx, %%ecx \n\t" - "sub %%edx, %%ecx \n\t" - "test %%ax, %%ax \n\t" - " jnz 1f \n\t" - "mov %a5(%2), %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" - "1: \n\t" - "movl %%eax, %a4(%2) \n\t" - - :"+c"(val), "=&r"(tmp) - :"r"(c), - "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), - "i"(offsetof(CABACContext, bytestream)) - : "%eax", "%edx", "memory" - ); - return val; -#else int range, mask; c->low += c->low; @@ -479,8 +371,8 @@ static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ range &= mask; c->low += range; return (val^mask)-mask; -#endif } +#endif /** * diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h new file mode 100644 index 0000000000..3e5a2217ae --- /dev/null +++ b/libavcodec/x86/cabac.h @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2003 Michael Niedermayer + * + * 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 AVCODEC_X86_CABAC_H +#define AVCODEC_X86_CABAC_H + +#include "libavcodec/cabac.h" +#include "libavutil/attributes.h" +#include "libavutil/x86_cpu.h" +#include "config.h" + +#if HAVE_FAST_CMOV +#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ + "mov "tmp" , %%ecx \n\t"\ + "shl $17 , "tmp" \n\t"\ + "cmp "low" , "tmp" \n\t"\ + "cmova %%ecx , "range" \n\t"\ + "sbb %%ecx , %%ecx \n\t"\ + "and %%ecx , "tmp" \n\t"\ + "sub "tmp" , "low" \n\t"\ + "xor %%ecx , "ret" \n\t" +#else /* HAVE_FAST_CMOV */ +#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ + "mov "tmp" , %%ecx \n\t"\ + "shl $17 , "tmp" \n\t"\ + "sub "low" , "tmp" \n\t"\ + "sar $31 , "tmp" \n\t" /*lps_mask*/\ + "sub %%ecx , "range" \n\t" /*RangeLPS - range*/\ + "and "tmp" , "range" \n\t" /*(RangeLPS - range)&lps_mask*/\ + "add %%ecx , "range" \n\t" /*new range*/\ + "shl $17 , %%ecx \n\t"\ + "and "tmp" , %%ecx \n\t"\ + "sub %%ecx , "low" \n\t"\ + "xor "tmp" , "ret" \n\t" +#endif /* HAVE_FAST_CMOV */ + +#define BRANCHLESS_GET_CABAC(ret, cabac, 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) \ + "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"\ + "mov "tmpbyte" , "statep" \n\t"\ + "shl %%cl , "low" \n\t"\ + "test "lowword" , "lowword" \n\t"\ + " jnz 1f \n\t"\ + "mov "byte"("cabac"), %%"REG_c" \n\t"\ + "movzwl (%%"REG_c") , "tmp" \n\t"\ + "bswap "tmp" \n\t"\ + "shr $15 , "tmp" \n\t"\ + "sub $0xFFFF , "tmp" \n\t"\ + "add $2 , %%"REG_c" \n\t"\ + "mov %%"REG_c" , "byte "("cabac") \n\t"\ + "lea -1("low") , %%ecx \n\t"\ + "xor "low" , %%ecx \n\t"\ + "shr $15 , %%ecx \n\t"\ + "movzbl " MANGLE(ff_h264_norm_shift) "(%%ecx), %%ecx \n\t"\ + "neg %%ecx \n\t"\ + "add $7 , %%ecx \n\t"\ + "shl %%cl , "tmp" \n\t"\ + "add "tmp" , "low" \n\t"\ + "1: \n\t" + +#if ARCH_X86 && HAVE_7REGS && !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) +{ + int bit, low, range, tmp; + + __asm__ volatile( + "movl %a6(%5), %2 \n\t" + "movl %a7(%5), %1 \n\t" + BRANCHLESS_GET_CABAC("%0", "%5", "(%4)", "%1", "%w1", "%2", + "%3", "%b3", "%a8") + "movl %2, %a6(%5) \n\t" + "movl %1, %a7(%5) \n\t" + + :"=&r"(bit), "=&r"(low), "=&r"(range), "=&r"(tmp) + :"r"(state), "r"(c), + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), + "i"(offsetof(CABACContext, bytestream)) + : "%"REG_c, "memory" + ); + return bit & 1; +} +#endif /* ARCH_X86 && HAVE_7REGS && !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" + "shl $17, %k1 \n\t" + "add %%eax, %%eax \n\t" + "sub %k1, %%eax \n\t" + "cltd \n\t" + "and %%edx, %k1 \n\t" + "add %k1, %%eax \n\t" + "xor %%edx, %%ecx \n\t" + "sub %%edx, %%ecx \n\t" + "test %%ax, %%ax \n\t" + " jnz 1f \n\t" + "mov %a5(%2), %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" + "1: \n\t" + "movl %%eax, %a4(%2) \n\t" + + :"+c"(val), "=&r"(tmp) + :"r"(c), + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), + "i"(offsetof(CABACContext, bytestream)) + : "%eax", "%edx", "memory" + ); + return val; +} + +#endif /* AVCODEC_X86_CABAC_H */ diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 9f5e53105e..af3addd848 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -32,6 +32,7 @@ #include #include "libavcodec/cabac.h" +#include "cabac.h" //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet //as that would make optimization work hard) -- cgit v1.2.3 From c5ee740745596941b84b738cc528ec85b0e6f0a3 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 20 Jun 2011 23:10:26 +0100 Subject: x86: cabac: fix register constraints for 32-bit mode Some operands need to be accessed in byte mode, which restricts the available registers in 32-bit mode. Using the 'q' constraint selects a suitable register. Signed-off-by: Mans Rullgard --- libavcodec/x86/cabac.h | 2 +- libavcodec/x86/h264_i386.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index 3e5a2217ae..52bea9c53d 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -98,7 +98,7 @@ static av_always_inline int get_cabac_inline_x86(CABACContext *c, "movl %2, %a6(%5) \n\t" "movl %1, %a7(%5) \n\t" - :"=&r"(bit), "=&r"(low), "=&r"(range), "=&r"(tmp) + :"=&r"(bit), "=&r"(low), "=&r"(range), "=&q"(tmp) :"r"(state), "r"(c), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index af3addd848..9c86210371 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -89,7 +89,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "movl %5, %a11(%6) \n\t" "movl %3, %a12(%6) \n\t" - :"=&r"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), + :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), "=&r"(low), "=&r"(bit), "=&r"(range) :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), @@ -157,7 +157,7 @@ static int decode_significance_8x8_x86(CABACContext *c, "movl %5, %a12(%7) \n\t" "movl %3, %a13(%7) \n\t" - :"=&r"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit), + :"=&q"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit), "=&r"(range), "=&r"(state) :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), -- cgit v1.2.3 From e6c52cee541ba23a7aec525f72dff73c188dad06 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 7 Jun 2011 13:40:22 -0400 Subject: Replace usages of av_get_bits_per_sample_fmt() with av_get_bytes_per_sample(). av_get_bits_per_sample_fmt() is deprecated. --- ffmpeg.c | 6 +++--- ffplay.c | 2 +- libavcodec/aacdec.c | 2 +- libavcodec/ac3dec.c | 2 +- libavcodec/alsdec.c | 4 ++-- libavcodec/dca.c | 2 +- libavcodec/resample.c | 4 ++-- libavcodec/utils.c | 2 +- libavcodec/vmdav.c | 2 +- libavcodec/vorbisdec.c | 2 +- libavfilter/defaults.c | 2 +- libavformat/matroskaenc.c | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index b28408741c..9f2d5b98b4 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -778,8 +778,8 @@ static void do_audio_out(AVFormatContext *s, int size_out, frame_bytes, ret, resample_changed; AVCodecContext *enc= ost->st->codec; AVCodecContext *dec= ist->st->codec; - int osize= av_get_bits_per_sample_fmt(enc->sample_fmt)/8; - int isize= av_get_bits_per_sample_fmt(dec->sample_fmt)/8; + int osize = av_get_bytes_per_sample(enc->sample_fmt); + int isize = av_get_bytes_per_sample(dec->sample_fmt); const int coded_bps = av_get_bits_per_sample(enc->codec->id); need_realloc: @@ -1481,7 +1481,7 @@ static int output_packet(AVInputStream *ist, int ist_index, #endif AVPacket avpkt; - int bps = av_get_bits_per_sample_fmt(ist->st->codec->sample_fmt)>>3; + int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt); if(ist->next_pts == AV_NOPTS_VALUE) ist->next_pts= ist->pts; diff --git a/ffplay.c b/ffplay.c index c9891d3cdc..ffd4c230b8 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2032,7 +2032,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) if (is->reformat_ctx) { const void *ibuf[6]= {is->audio_buf1}; void *obuf[6]= {is->audio_buf2}; - int istride[6]= {av_get_bits_per_sample_fmt(dec->sample_fmt)/8}; + int istride[6]= {av_get_bytes_per_sample(dec->sample_fmt)}; int ostride[6]= {2}; int len= data_size/istride[0]; if (av_audio_convert(is->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) { diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 69aacb86d6..26ce204257 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -2177,7 +2177,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, } data_size_tmp = samples * avctx->channels * - (av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8); + av_get_bytes_per_sample(avctx->sample_fmt); if (*data_size < data_size_tmp) { av_log(avctx, AV_LOG_ERROR, "Output buffer too small (%d) or trying to output too many samples (%d) for this frame.\n", diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 2966c33b25..42b62ef701 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1422,7 +1422,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, } } *data_size = s->num_blocks * 256 * avctx->channels * - (av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8); + av_get_bytes_per_sample(avctx->sample_fmt); return FFMIN(buf_size, s->frame_size); } diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 17c54900f7..055bfd0d04 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -1450,7 +1450,7 @@ static int decode_frame(AVCodecContext *avctx, // check for size of decoded data size = ctx->cur_frame_length * avctx->channels * - (av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3); + av_get_bytes_per_sample(avctx->sample_fmt); if (size > *data_size) { av_log(avctx, AV_LOG_ERROR, "Decoded data exceeds buffer size.\n"); @@ -1714,7 +1714,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ctx->crc_buffer = av_malloc(sizeof(*ctx->crc_buffer) * ctx->cur_frame_length * avctx->channels * - (av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3)); + av_get_bytes_per_sample(avctx->sample_fmt)); if (!ctx->crc_buffer) { av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); decode_end(avctx); diff --git a/libavcodec/dca.c b/libavcodec/dca.c index a9b2c9b0c9..68731c9033 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -1813,7 +1813,7 @@ static int dca_decode_frame(AVCodecContext * avctx, } out_size = 256 / 8 * s->sample_blocks * channels * - (av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8); + av_get_bytes_per_sample(avctx->sample_fmt); if (*data_size < out_size) return -1; *data_size = out_size; diff --git a/libavcodec/resample.c b/libavcodec/resample.c index 0bebe1ab88..04bbbf07e4 100644 --- a/libavcodec/resample.c +++ b/libavcodec/resample.c @@ -187,8 +187,8 @@ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, s->sample_fmt[0] = sample_fmt_in; s->sample_fmt[1] = sample_fmt_out; - s->sample_size[0] = av_get_bits_per_sample_fmt(s->sample_fmt[0]) >> 3; - s->sample_size[1] = av_get_bits_per_sample_fmt(s->sample_fmt[1]) >> 3; + s->sample_size[0] = av_get_bytes_per_sample(s->sample_fmt[0]); + s->sample_size[1] = av_get_bytes_per_sample(s->sample_fmt[1]); if (s->sample_fmt[0] != AV_SAMPLE_FMT_S16) { if (!(s->convert_ctx[0] = av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1, diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1e5886473d..146dd306c3 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1131,7 +1131,7 @@ int av_get_bits_per_sample(enum CodecID codec_id){ #if FF_API_OLD_SAMPLE_FMT int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt) { - return av_get_bits_per_sample_fmt(sample_fmt); + return av_get_bytes_per_sample(sample_fmt) << 3; } #endif diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index d258252d95..283c2136d5 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -447,7 +447,7 @@ static av_cold int vmdaudio_decode_init(AVCodecContext *avctx) avctx->sample_fmt = AV_SAMPLE_FMT_S16; else avctx->sample_fmt = AV_SAMPLE_FMT_U8; - s->out_bps = av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3; + s->out_bps = av_get_bytes_per_sample(avctx->sample_fmt); av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, " "block align = %d, sample rate = %d\n", diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 017102e777..9fc60688a2 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1646,7 +1646,7 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, vc->audio_channels); *data_size = len * vc->audio_channels * - (av_get_bits_per_sample_fmt(avccontext->sample_fmt) / 8); + av_get_bytes_per_sample(avccontext->sample_fmt); return buf_size ; } diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c index 146f1c7105..b891ab1f22 100644 --- a/libavfilter/defaults.c +++ b/libavfilter/defaults.c @@ -84,7 +84,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per samples->refcount = 1; samples->free = ff_avfilter_default_free_buffer; - sample_size = av_get_bits_per_sample_fmt(sample_fmt) >>3; + sample_size = av_get_bytes_per_sample(sample_fmt); chans_nb = av_get_channel_layout_nb_channels(channel_layout); per_channel_size = size/chans_nb; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index fde1470f9a..e485539a26 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -527,7 +527,7 @@ static int mkv_write_tracks(AVFormatContext *s) AVDictionaryEntry *tag; if (!bit_depth) - bit_depth = av_get_bits_per_sample_fmt(codec->sample_fmt); + bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3; if (codec->codec_id == CODEC_ID_AAC) get_aac_sample_rates(s, codec, &sample_rate, &output_sample_rate); -- cgit v1.2.3