[PATCH 1/6] flacdec: change variable-length array to fixed length
pred_order can never exceed 64, so always allocating that amount is safe and not very wasteful. --- libavcodec/flacdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 4ff7fae..643ed24 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -358,7 +358,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order) { int i, j; int coeff_prec, qlevel; - int coeffs[pred_order]; + int coeffs[64]; int32_t *decoded = s->decoded[channel]; /* warm up samples */ -- 1.6.4
The difference between 188 and 204 is not worth worrying about. --- libavformat/mpegts.c | 2 +- libavformat/mpegts.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 6c0c314..69623ac 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -355,7 +355,7 @@ static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter) } static int analyze(const uint8_t *buf, int size, int packet_size, int *index){ - int stat[packet_size]; + int stat[TS_MAX_PACKET_SIZE]; int i; int x=0; int best_score=0; diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h index e5df071..7c4e73c 100644 --- a/libavformat/mpegts.h +++ b/libavformat/mpegts.h @@ -27,6 +27,8 @@ #define TS_FEC_PACKET_SIZE 204 #define TS_DVHS_PACKET_SIZE 192 #define TS_PACKET_SIZE 188 +#define TS_MAX_PACKET_SIZE 204 + #define NB_PID_MAX 8192 #define MAX_SECTION_SIZE 4096 -- 1.6.4
Mans Rullgard <mans at mansr.com> writes:
The difference between 188 and 204 is not worth worrying about. --- libavformat/mpegts.c | 2 +- libavformat/mpegts.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletions(-)
ping -- M?ns Rullg?rd mans at mansr.com
On 08/22/2009 06:46 AM, M?ns Rullg?rd wrote:
Mans Rullgard<mans at mansr.com> writes:
The difference between 188 and 204 is not worth worrying about. --- libavformat/mpegts.c | 2 +- libavformat/mpegts.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletions(-)
ping
Patch ok :) -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
Baptiste Coudurier <baptiste.coudurier at gmail.com> writes:
On 08/22/2009 06:46 AM, M?ns Rullg?rd wrote:
Mans Rullgard<mans at mansr.com> writes:
The difference between 188 and 204 is not worth worrying about. --- libavformat/mpegts.c | 2 +- libavformat/mpegts.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletions(-)
ping
Patch ok :)
Applied. -- M?ns Rullg?rd mans at mansr.com
There is a theoretical possibility to pass a very long string to ff_parse, which could crash if allocated from the stack. This allows the allocation to be checked properly. --- libavcodec/eval.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/eval.c b/libavcodec/eval.c index 95e9310..1d52ba5 100644 --- a/libavcodec/eval.c +++ b/libavcodec/eval.c @@ -369,8 +369,12 @@ AVEvalExpr * ff_parse(const char *s, const char * const *const_name, double (**func2)(void *, double, double), const char **func2_name, const char **error){ Parser p; - AVEvalExpr * e; - char w[strlen(s) + 1], * wp = w; + AVEvalExpr *e = NULL; + char *w = av_malloc(strlen(s) + 1); + char *wp = w; + + if (!w) + goto end; while (*s) if (!isspace(*s++)) *wp++ = s[-1]; @@ -388,8 +392,10 @@ AVEvalExpr * ff_parse(const char *s, const char * const *const_name, e = parse_expr(&p); if (!verify_expr(e)) { ff_eval_free(e); - return NULL; + e = NULL; } +end: + av_free(w); return e; } -- 1.6.4
On Wed, Aug 19, 2009 at 02:22:59AM +0100, Mans Rullgard wrote:
There is a theoretical possibility to pass a very long string to ff_parse, which could crash if allocated from the stack. This allows the allocation to be checked properly. --- libavcodec/eval.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is not what we do, but why we do it that matters.
Michael Niedermayer <michaelni at gmx.at> writes:
On Wed, Aug 19, 2009 at 02:22:59AM +0100, Mans Rullgard wrote:
There is a theoretical possibility to pass a very long string to ff_parse, which could crash if allocated from the stack. This allows the allocation to be checked properly. --- libavcodec/eval.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
ok
Applied. -- M?ns Rullg?rd mans at mansr.com
MAX_STREAMS is small enough that it doesn't matter --- libavformat/asfdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 0995b5a..5d90f45 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -994,7 +994,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pts; int64_t pos= *ppos; int i; - int64_t start_pos[s->nb_streams]; + int64_t start_pos[MAX_STREAMS]; for(i=0; i<s->nb_streams; i++){ start_pos[i]= pos; -- 1.6.4
Mans Rullgard <mans at mansr.com> writes:
MAX_STREAMS is small enough that it doesn't matter --- libavformat/asfdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
ping -- M?ns Rullg?rd mans at mansr.com
ssOn Wed, Aug 19, 2009 at 02:23:00AM +0100, Mans Rullgard wrote:
MAX_STREAMS is small enough that it doesn't matter --- libavformat/asfdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
we wanted to get rid of MAX_STREAMS limits thus this one would be just moving more work on the poor guy who actually tries to get rid of it [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator
Michael Niedermayer <michaelni at gmx.at> writes:
ssOn Wed, Aug 19, 2009 at 02:23:00AM +0100, Mans Rullgard wrote:
MAX_STREAMS is small enough that it doesn't matter --- libavformat/asfdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
we wanted to get rid of MAX_STREAMS limits thus this one would be just moving more work on the poor guy who actually tries to get rid of it
Good point, but then we should still do something else with this, since if that limit goes away, this would be requesting an unbounded amount of stack space, which is not a good idea. Is malloc/free acceptable in this function? -- M?ns Rullg?rd mans at mansr.com
On Sat, Aug 22, 2009 at 04:03:25PM +0100, M?ns Rullg?rd wrote:
Michael Niedermayer <michaelni at gmx.at> writes:
ssOn Wed, Aug 19, 2009 at 02:23:00AM +0100, Mans Rullgard wrote:
MAX_STREAMS is small enough that it doesn't matter --- libavformat/asfdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
we wanted to get rid of MAX_STREAMS limits thus this one would be just moving more work on the poor guy who actually tries to get rid of it
Good point, but then we should still do something else with this, since if that limit goes away, this would be requesting an unbounded amount of stack space, which is not a good idea. Is malloc/free acceptable in this function?
yes i think so, it seems not called often enough [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are too smart to engage in politics are punished by being governed by those who are dumber. -- Plato
--- libavcodec/vorbis_dec.c | 42 +++++++++++++++++++++++++++++++----------- 1 files changed, 31 insertions(+), 11 deletions(-) diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c index bb582c2..4edb234 100644 --- a/libavcodec/vorbis_dec.c +++ b/libavcodec/vorbis_dec.c @@ -104,6 +104,8 @@ typedef struct { uint_fast8_t classbook; int_fast16_t books[64][8]; uint_fast8_t maxpass; + uint_fast16_t ptns_to_read; + uint_fast8_t *classifs; } vorbis_residue; typedef struct { @@ -155,6 +157,9 @@ typedef struct vorbis_context_s { float *saved; uint_fast32_t add_bias; // for float->int conversion uint_fast32_t exp_bias; + uint_fast8_t *no_residue; + uint_fast8_t *do_not_decode; + uint_fast8_t *res_chan; } vorbis_context; /* Helper functions */ @@ -178,7 +183,12 @@ static void vorbis_free(vorbis_context *vc) { av_freep(&vc->channel_residues); av_freep(&vc->channel_floors); av_freep(&vc->saved); + av_freep(&vc->no_residue); + av_freep(&vc->do_not_decode); + av_freep(&vc->res_chan); + for (i = 0; i < vc->residue_count; i++) + av_free(vc->residues[i].classifs); av_freep(&vc->residues); av_freep(&vc->modes); @@ -220,6 +230,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { uint_fast16_t cb; uint8_t *tmp_vlc_bits; uint32_t *tmp_vlc_codes; + uint_fast16_t *codebook_multiplicands; GetBitContext *gb=&vc->gb; vc->codebook_count=get_bits(gb,8)+1; @@ -229,6 +240,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { vc->codebooks=av_mallocz(vc->codebook_count * sizeof(vorbis_codebook)); tmp_vlc_bits =av_mallocz(V_MAX_VLCS * sizeof(uint8_t)); tmp_vlc_codes=av_mallocz(V_MAX_VLCS * sizeof(uint32_t)); + codebook_multiplicands = av_malloc(V_MAX_VLCS * sizeof(*codebook_multiplicands)); for(cb=0;cb<vc->codebook_count;++cb) { vorbis_codebook *codebook_setup=&vc->codebooks[cb]; @@ -322,7 +334,6 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { if (codebook_setup->lookup_type==1) { uint_fast16_t i, j, k; uint_fast16_t codebook_lookup_values=ff_vorbis_nth_root(entries, codebook_setup->dimensions); - uint_fast16_t codebook_multiplicands[codebook_lookup_values]; float codebook_minimum_value=vorbisfloat2float(get_bits_long(gb, 32)); float codebook_delta_value=vorbisfloat2float(get_bits_long(gb, 32)); @@ -406,12 +417,14 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); + av_free(codebook_multiplicands); return 0; // Error: error: av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); + av_free(codebook_multiplicands); return 1; } @@ -631,6 +644,11 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc){ res_setup->partition_size=get_bits(gb, 24)+1; res_setup->classifications=get_bits(gb, 6)+1; res_setup->classbook=get_bits(gb, 8); + res_setup->ptns_to_read = + (res_setup->end - res_setup->begin) / res_setup->partition_size; + res_setup->classifs = av_malloc(res_setup->ptns_to_read * + vc->audio_channels * + sizeof(*res_setup->classifs)); AV_DEBUG(" begin %d end %d part.size %d classif.s %d classbook %d \n", res_setup->begin, res_setup->end, res_setup->partition_size, res_setup->classifications, res_setup->classbook); @@ -879,6 +897,9 @@ static int vorbis_parse_id_hdr(vorbis_context *vc){ vc->channel_residues= av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); vc->channel_floors = av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); vc->saved = av_mallocz((vc->blocksize[1]/4)*vc->audio_channels * sizeof(float)); + vc->no_residue = av_malloc(vc->audio_channels*sizeof(*vc->no_residue)); + vc->do_not_decode = av_malloc(vc->audio_channels*sizeof(*vc->do_not_decode)); + vc->res_chan = av_malloc(vc->audio_channels*sizeof(*vc->res_chan)); vc->previous_window=0; ff_mdct_init(&vc->mdct[0], bl0, 1, vc->exp_bias ? -(1<<15) : -1.0); @@ -1084,9 +1105,9 @@ static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data * GetBitContext *gb=&vc->gb; uint_fast16_t range_v[4]={ 256, 128, 86, 64 }; uint_fast16_t range=range_v[vf->multiplier-1]; - uint_fast16_t floor1_Y[vf->x_list_dim]; - uint_fast16_t floor1_Y_final[vf->x_list_dim]; - int floor1_flag[vf->x_list_dim]; + uint_fast16_t floor1_Y[258]; + uint_fast16_t floor1_Y_final[258]; + int floor1_flag[258]; uint_fast8_t class_; uint_fast8_t cdim; uint_fast8_t cbits; @@ -1213,9 +1234,8 @@ static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data * static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, int vr_type) { GetBitContext *gb=&vc->gb; uint_fast8_t c_p_c=vc->codebooks[vr->classbook].dimensions; - uint_fast16_t n_to_read=vr->end-vr->begin; - uint_fast16_t ptns_to_read=n_to_read/vr->partition_size; - uint_fast8_t classifs[ptns_to_read*vc->audio_channels]; + uint_fast16_t ptns_to_read = vr->ptns_to_read; + uint_fast8_t *classifs = vr->classifs; uint_fast8_t pass; uint_fast8_t ch_used; uint_fast8_t i,j,l; @@ -1412,12 +1432,12 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) { uint_fast8_t blockflag; uint_fast16_t blocksize; int_fast32_t i,j; - uint_fast8_t no_residue[vc->audio_channels]; - uint_fast8_t do_not_decode[vc->audio_channels]; + uint_fast8_t *no_residue = vc->no_residue; + uint_fast8_t *do_not_decode = vc->do_not_decode; vorbis_mapping *mapping; float *ch_res_ptr=vc->channel_residues; float *ch_floor_ptr=vc->channel_floors; - uint_fast8_t res_chan[vc->audio_channels]; + uint_fast8_t *res_chan = vc->res_chan; uint_fast8_t res_num=0; int_fast16_t retlen=0; float fadd_bias = vc->add_bias; @@ -1550,7 +1570,7 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, int buf_size = avpkt->size; vorbis_context *vc = avccontext->priv_data ; GetBitContext *gb = &(vc->gb); - const float *channel_ptrs[vc->audio_channels]; + const float *channel_ptrs[255]; int i; int_fast16_t len; -- 1.6.4
Mans Rullgard <mans at mansr.com> writes:
--- libavcodec/vorbis_dec.c | 42 +++++++++++++++++++++++++++++++----------- 1 files changed, 31 insertions(+), 11 deletions(-)
ping -- M?ns Rullg?rd mans at mansr.com
Mans Rullgard <mans at mansr.com> writes:
--- libavcodec/vorbis_dec.c | 42 +++++++++++++++++++++++++++++++----------- 1 files changed, 31 insertions(+), 11 deletions(-)
ping -- M?ns Rullg?rd mans at mansr.com
On Aug 18, 2009, at 9:23 PM, Mans Rullgard wrote:
--- libavcodec/vorbis_dec.c | 42 +++++++++++++++++++++++++++++++----------- 1 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c index bb582c2..4edb234 100644 --- a/libavcodec/vorbis_dec.c +++ b/libavcodec/vorbis_dec.c @@ -104,6 +104,8 @@ typedef struct { uint_fast8_t classbook; int_fast16_t books[64][8]; uint_fast8_t maxpass; + uint_fast16_t ptns_to_read; + uint_fast8_t *classifs; } vorbis_residue;
typedef struct { @@ -155,6 +157,9 @@ typedef struct vorbis_context_s { float *saved; uint_fast32_t add_bias; // for float->int conversion uint_fast32_t exp_bias; + uint_fast8_t *no_residue; + uint_fast8_t *do_not_decode; + uint_fast8_t *res_chan; } vorbis_context;
/* Helper functions */ @@ -178,7 +183,12 @@ static void vorbis_free(vorbis_context *vc) { av_freep(&vc->channel_residues); av_freep(&vc->channel_floors); av_freep(&vc->saved); + av_freep(&vc->no_residue); + av_freep(&vc->do_not_decode); + av_freep(&vc->res_chan);
+ for (i = 0; i < vc->residue_count; i++) + av_free(vc->residues[i].classifs); av_freep(&vc->residues); av_freep(&vc->modes);
@@ -220,6 +230,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { uint_fast16_t cb; uint8_t *tmp_vlc_bits; uint32_t *tmp_vlc_codes; + uint_fast16_t *codebook_multiplicands; GetBitContext *gb=&vc->gb;
vc->codebook_count=get_bits(gb,8)+1; @@ -229,6 +240,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { vc->codebooks=av_mallocz(vc->codebook_count * sizeof(vorbis_codebook)); tmp_vlc_bits =av_mallocz(V_MAX_VLCS * sizeof(uint8_t)); tmp_vlc_codes=av_mallocz(V_MAX_VLCS * sizeof(uint32_t)); + codebook_multiplicands = av_malloc(V_MAX_VLCS * sizeof(*codebook_multiplicands));
for(cb=0;cb<vc->codebook_count;++cb) { vorbis_codebook *codebook_setup=&vc->codebooks[cb]; @@ -322,7 +334,6 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { if (codebook_setup->lookup_type==1) { uint_fast16_t i, j, k; uint_fast16_t codebook_lookup_values=ff_vorbis_nth_root(entries, codebook_setup->dimensions); - uint_fast16_t codebook_multiplicands[codebook_lookup_values];
float codebook_minimum_value=vorbisfloat2float(get_bits_long(gb, 32)); float codebook_delta_value=vorbisfloat2float(get_bits_long(gb, 32)); @@ -406,12 +417,14 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) {
av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); + av_free(codebook_multiplicands); return 0;
// Error: error: av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); + av_free(codebook_multiplicands); return 1; }
@@ -631,6 +644,11 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc){ res_setup->partition_size=get_bits(gb, 24)+1; res_setup->classifications=get_bits(gb, 6)+1; res_setup->classbook=get_bits(gb, 8); + res_setup->ptns_to_read = + (res_setup->end - res_setup->begin) / res_setup->partition_size; + res_setup->classifs = av_malloc(res_setup->ptns_to_read * + vc->audio_channels * + sizeof(*res_setup->classifs));
AV_DEBUG(" begin %d end %d part.size %d classif.s %d classbook %d \n", res_setup->begin, res_setup->end, res_setup->partition_size, res_setup->classifications, res_setup->classbook); @@ -879,6 +897,9 @@ static int vorbis_parse_id_hdr(vorbis_context *vc){ vc->channel_residues= av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); vc->channel_floors = av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); vc->saved = av_mallocz((vc->blocksize[1]/4)*vc->audio_channels * sizeof(float)); + vc->no_residue = av_malloc(vc->audio_channels*sizeof(*vc->no_residue)); + vc->do_not_decode = av_malloc(vc->audio_channels*sizeof(*vc->do_not_decode)); + vc->res_chan = av_malloc(vc->audio_channels*sizeof(*vc->res_chan)); vc->previous_window=0;
ff_mdct_init(&vc->mdct[0], bl0, 1, vc->exp_bias ? -(1<<15) : -1.0); @@ -1084,9 +1105,9 @@ static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data * GetBitContext *gb=&vc->gb; uint_fast16_t range_v[4]={ 256, 128, 86, 64 }; uint_fast16_t range=range_v[vf->multiplier-1]; - uint_fast16_t floor1_Y[vf->x_list_dim]; - uint_fast16_t floor1_Y_final[vf->x_list_dim]; - int floor1_flag[vf->x_list_dim]; + uint_fast16_t floor1_Y[258]; + uint_fast16_t floor1_Y_final[258]; + int floor1_flag[258]; uint_fast8_t class_; uint_fast8_t cdim; uint_fast8_t cbits; @@ -1213,9 +1234,8 @@ static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data * static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, int vr_type) { GetBitContext *gb=&vc->gb; uint_fast8_t c_p_c=vc->codebooks[vr->classbook].dimensions; - uint_fast16_t n_to_read=vr->end-vr->begin; - uint_fast16_t ptns_to_read=n_to_read/vr->partition_size; - uint_fast8_t classifs[ptns_to_read*vc->audio_channels]; + uint_fast16_t ptns_to_read = vr->ptns_to_read; + uint_fast8_t *classifs = vr->classifs; uint_fast8_t pass; uint_fast8_t ch_used; uint_fast8_t i,j,l; @@ -1412,12 +1432,12 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) { uint_fast8_t blockflag; uint_fast16_t blocksize; int_fast32_t i,j; - uint_fast8_t no_residue[vc->audio_channels]; - uint_fast8_t do_not_decode[vc->audio_channels]; + uint_fast8_t *no_residue = vc->no_residue; + uint_fast8_t *do_not_decode = vc->do_not_decode; vorbis_mapping *mapping; float *ch_res_ptr=vc->channel_residues; float *ch_floor_ptr=vc->channel_floors; - uint_fast8_t res_chan[vc->audio_channels]; + uint_fast8_t *res_chan = vc->res_chan;
These 3 can be a constant 255 like channel_ptrs. Other than that, okay
uint_fast8_t res_num=0; int_fast16_t retlen=0; float fadd_bias = vc->add_bias; @@ -1550,7 +1570,7 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, int buf_size = avpkt->size; vorbis_context *vc = avccontext->priv_data ; GetBitContext *gb = &(vc->gb); - const float *channel_ptrs[vc->audio_channels]; + const float *channel_ptrs[255]; int i;
int_fast16_t len; -- 1.6.4
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
David Conrad <lessen42 at gmail.com> writes:
- uint_fast8_t no_residue[vc->audio_channels]; - uint_fast8_t do_not_decode[vc->audio_channels]; + uint_fast8_t *no_residue = vc->no_residue; + uint_fast8_t *do_not_decode = vc->do_not_decode; vorbis_mapping *mapping; float *ch_res_ptr=vc->channel_residues; float *ch_floor_ptr=vc->channel_floors; - uint_fast8_t res_chan[vc->audio_channels]; + uint_fast8_t *res_chan = vc->res_chan;
These 3 can be a constant 255 like channel_ptrs.
I wonder what I was thinking...
Other than that, okay
Applied with that change. -- M?ns Rullg?rd mans at mansr.com
--- libavcodec/dsputil.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 871d1c7..8efe9ed 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -3831,9 +3831,11 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int MpegEncContext * const s= (MpegEncContext *)c; const uint8_t *scantable= s->intra_scantable.permutated; DECLARE_ALIGNED_8 (uint64_t, aligned_temp[sizeof(DCTELEM)*64/8]); - DECLARE_ALIGNED_8 (uint64_t, aligned_bak[stride]); + DECLARE_ALIGNED_8 (uint64_t, aligned_src1[8]); + DECLARE_ALIGNED_8 (uint64_t, aligned_src2[8]); DCTELEM * const temp= (DCTELEM*)aligned_temp; - uint8_t * const bak= (uint8_t*)aligned_bak; + uint8_t * const lsrc1 = (uint8_t*)aligned_src1; + uint8_t * const lsrc2 = (uint8_t*)aligned_src2; int i, last, run, bits, level, distortion, start_i; const int esc_length= s->ac_esc_length; uint8_t * length; @@ -3841,12 +3843,10 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int assert(h==8); - for(i=0; i<8; i++){ - ((uint32_t*)(bak + i*stride))[0]= ((uint32_t*)(src2 + i*stride))[0]; - ((uint32_t*)(bak + i*stride))[1]= ((uint32_t*)(src2 + i*stride))[1]; - } + copy_block8(lsrc1, src1, 8, stride, 8); + copy_block8(lsrc2, src2, 8, stride, 8); - s->dsp.diff_pixels(temp, src1, src2, stride); + s->dsp.diff_pixels(temp, lsrc1, lsrc2, 8); s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i); @@ -3899,9 +3899,9 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int s->dct_unquantize_inter(s, temp, 0, s->qscale); } - s->dsp.idct_add(bak, stride, temp); + s->dsp.idct_add(lsrc2, 8, temp); - distortion= s->dsp.sse[1](NULL, bak, src1, stride, 8); + distortion= s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8); return distortion + ((bits*s->qscale*s->qscale*109 + 64)>>7); } -- 1.6.4
On Wed, Aug 19, 2009 at 02:23:02AM +0100, Mans Rullgard wrote:
--- libavcodec/dsputil.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
ok, if tested [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope
Michael Niedermayer <michaelni at gmx.at> writes:
On Wed, Aug 19, 2009 at 02:23:02AM +0100, Mans Rullgard wrote:
--- libavcodec/dsputil.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
ok, if tested
Tested, applied. -- M?ns Rullg?rd mans at mansr.com
Mans Rullgard wrote:
pred_order can never exceed 64, so always allocating that amount is safe and not very wasteful. --- libavcodec/flacdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 4ff7fae..643ed24 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -358,7 +358,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order) { int i, j; int coeff_prec, qlevel; - int coeffs[pred_order]; + int coeffs[64]; int32_t *decoded = s->decoded[channel];
/* warm up samples */
That should be 32, not 64. -Justin
Justin Ruggles <justin.ruggles at gmail.com> writes:
Mans Rullgard wrote:
pred_order can never exceed 64, so always allocating that amount is safe and not very wasteful. --- libavcodec/flacdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 4ff7fae..643ed24 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -358,7 +358,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order) { int i, j; int coeff_prec, qlevel; - int coeffs[pred_order]; + int coeffs[64]; int32_t *decoded = s->decoded[channel];
/* warm up samples */
That should be 32, not 64.
You're right. I just saw the get_bits(6). OK with that change? -- M?ns Rullg?rd mans at mansr.com
M?ns Rullg?rd wrote:
Justin Ruggles <justin.ruggles at gmail.com> writes:
Mans Rullgard wrote:
pred_order can never exceed 64, so always allocating that amount is safe and not very wasteful. --- libavcodec/flacdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 4ff7fae..643ed24 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -358,7 +358,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order) { int i, j; int coeff_prec, qlevel; - int coeffs[pred_order]; + int coeffs[64]; int32_t *decoded = s->decoded[channel];
/* warm up samples */ That should be 32, not 64.
You're right. I just saw the get_bits(6).
OK with that change?
yes.
Justin Ruggles <justin.ruggles at gmail.com> writes:
M?ns Rullg?rd wrote:
Justin Ruggles <justin.ruggles at gmail.com> writes:
Mans Rullgard wrote:
pred_order can never exceed 64, so always allocating that amount is safe and not very wasteful. --- libavcodec/flacdec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 4ff7fae..643ed24 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -358,7 +358,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order) { int i, j; int coeff_prec, qlevel; - int coeffs[pred_order]; + int coeffs[64]; int32_t *decoded = s->decoded[channel];
/* warm up samples */ That should be 32, not 64.
You're right. I just saw the get_bits(6).
OK with that change?
yes.
Applied. -- M?ns Rullg?rd mans at mansr.com
participants (5)
-
baptiste.coudurier@gmail.com -
justin.ruggles@gmail.com -
lessen42@gmail.com -
mans@mansr.com -
michaelni@gmx.at