[Ffmpeg-devel] [PATCH] ported SGI decoder to the new API
Xiaohui Sun
sunxiaohui
Tue Mar 27 17:11:13 CEST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
Michael Niedermayer wrote:
> Hi
>
> On Tue, Mar 27, 2007 at 03:34:39PM +0800, Xiaohui Sun wrote:
>> Hi,
>> I have updated the path, Thank you again for your suggestions about
>> my code.
>>
>> the new patch
>> -- ported SGI encoder
>> -- seperate encoder/decoder into two files
>> -- fixed some problems of the previous code
>
> [...]
>
>> + for (y = s->height - 1; y >= 0; y--) {
>> + dest_row = ptr + (y * s->linesize);
>> + for (x = s->width; x > 0; x--) {
>> + dest_row[chan_offset] = bytestream_get_byte(&buf);
>> + dest_row += s->depth;
>> + }
>> + }
>
> sequential writes with random reads are faster then sequential reads with
> random writes
>
I should alloc an separate buffer, read the data in and use memcpy() to
do a sequential writes?
[...]
> [...]
>> +static int encode_init(AVCodecContext *avctx){
>> + SgiContext *s = avctx->priv_data;
>> +
>> + avcodec_get_frame_defaults((AVFrame*)&s->picture);
>> + avctx->coded_frame = (AVFrame*)&s->picture;
>> +
>> + return 0;
>> +}
>
> code duplication
>
>
the structure of the avctx->priv_data is not the same in encode and decode
> [...]
>> +static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
>> + int buf_size, void *data){
>> + SgiContext *s = avctx->priv_data;
>> + AVFrame * const p = &s->picture;
>> + long *offsettab, *lengthtab;
>> + int i, y, z;
>> + int tablesize, chan_offset;
>> + uint8_t *srcrow;
>> + unsigned int width, height, depth, dimension;
>> + unsigned int n_bytes;
>> + unsigned char *buf0 = buf;
>> +
>
> there are no checks for buf_size being large enough
>
>
we can not get the encoded image size before we actually encode it
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGCTQR+BwsLu3sVWwRAosQAJ9zF3nVuvANfeaCVWekAfhIpiHnCACff2fz
muhh54hiDrm5ddlDSOyfmqs=
=a2Ir
-----END PGP SIGNATURE-----
More information about the ffmpeg-devel
mailing list