[FFmpeg-cvslog] r22974 - trunk/libavcodec/iff.c
Michael Niedermayer
michaelni
Tue Apr 27 02:28:44 CEST 2010
On Tue, Apr 27, 2010 at 12:37:13AM +0200, rbultje wrote:
> Author: rbultje
> Date: Tue Apr 27 00:37:13 2010
> New Revision: 22974
>
> Log:
> Switch some ints to unsigned (they can only have positive values, this allows
> compiler to optimize some math from mul/div to shr/shl).
> Also add a cast to
> uint32_t when calling decodeplane32().
and why?
and who approved this patch?
review below:
[...]
> @@ -31,7 +32,7 @@
>
> typedef struct {
> AVFrame frame;
> - int planesize;
> + unsigned planesize;
never used in >> or /
> uint8_t * planebuf;
> } IffContext;
>
> @@ -40,7 +41,7 @@ typedef struct {
> */
> int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
> {
> - int count, i;
> + unsigned count, i;
never used in >> or /
other variables not checked but i suspect these arent the only ones
>
> if (avctx->bits_per_coded_sample > 8) {
> av_log(avctx, AV_LOG_ERROR, "bit_per_coded_sample > 8 not supported\n");
> @@ -71,7 +72,7 @@ static av_cold int decode_init(AVCodecCo
> return AVERROR_INVALIDDATA;
> }
>
> - s->planesize = avctx->width / 8;
> + s->planesize = avctx->width >> 3;
> s->planebuf = av_malloc(s->planesize + FF_INPUT_BUFFER_PADDING_SIZE);
> if (!s->planebuf)
> return AVERROR(ENOMEM);
> @@ -97,12 +98,11 @@ static av_cold int decode_init(AVCodecCo
> static void decodeplane8(uint8_t *dst, const uint8_t *const buf, int buf_size, int bps, int plane)
> {
> GetBitContext gb;
> - int i, b;
> + unsigned int i;
> + const unsigned b = (buf_size * 8) + bps - 1;
> init_get_bits(&gb, buf, buf_size * 8);
> - for(i = 0; i < (buf_size * 8 + bps - 1) / bps; i++) {
> - for (b = 0; b < bps; b++) {
> - dst[ i*bps + b ] |= get_bits1(&gb) << plane;
> - }
> + for(i = 0; i < b; i++) {
> + dst[i] |= get_bits1(&gb) << plane;
> }
> }
unrelated change
>
> @@ -117,12 +117,11 @@ static void decodeplane8(uint8_t *dst, c
> static void decodeplane32(uint32_t *dst, const uint8_t *const buf, int buf_size, int bps, int plane)
> {
> GetBitContext gb;
> - int i, b;
> + unsigned i;
> + const unsigned b = (buf_size * 8) + bps - 1;
> init_get_bits(&gb, buf, buf_size * 8);
> - for(i = 0; i < (buf_size * 8 + bps - 1) / bps; i++) {
> - for (b = 0; b < bps; b++) {
> - dst[ i*bps + b ] |= get_bits1(&gb) << plane;
> - }
> + for(i = 0; i < b; i++) {
> + dst[i] |= get_bits1(&gb) << plane;
> }
> }
same
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20100427/c06af1dc/attachment.pgp>
More information about the ffmpeg-cvslog
mailing list