[vlc-devel] [PATCH v2] codec: jpeg encoder implemented
Maxim Bublis
b at codemonkey.ru
Tue Jan 28 14:46:29 CET 2014
>
> > +}
> > +
> > +static block_t *EncodeBlock(encoder_t *p_enc, picture_t *p_pic)
> > +{
> > + encoder_sys_t *p_sys = p_enc->p_sys;
> > +
> > + const int bytesPerPixel = p_enc->fmt_out.video.i_bits_per_pixel ?
> > + p_enc->fmt_out.video.i_bits_per_pixel /
> 8 : 3;
>
> You should rather set *input* video format in Open
>
> > + const int blocksize = bytesPerPixel *
> p_enc->fmt_in.video.i_visible_width * p_enc->fmt_in.video.i_visible_height;
> > +
> > + block_t *p_block = block_Alloc(blocksize);
> > + if (p_block == NULL)
> > + {
> > + return NULL;
> > + }
> > +
> > + struct jpeg_compress_struct p_jpeg;
> > + JSAMPIMAGE p_row_pointers = NULL;
> > +
> > + p_jpeg.err = jpeg_std_error(&p_sys->err);
> > + p_sys->err.error_exit = encoder_error_exit;
> > + p_sys->err.output_message = encoder_error_message;
> > +
> > + /* libjpeg longjmp's there in case of error */
> > + if (setjmp(p_sys->setjmp_buffer))
> > + {
> > + goto error;
> > + }
> > +
> > + jpeg_create_compress(&p_jpeg);
> > + jpeg_mem_dest(&p_jpeg, &p_block->p_buffer, &p_block->i_buffer);
> > +
> > + p_jpeg.image_width = p_enc->fmt_in.video.i_visible_width;
> > + p_jpeg.image_height = p_enc->fmt_in.video.i_visible_height;
> > + p_jpeg.input_components = bytesPerPixel;
> > + p_jpeg.in_color_space = JCS_YCbCr;
> > +
> > + jpeg_set_defaults(&p_jpeg);
> > + jpeg_set_colorspace(&p_jpeg, JCS_YCbCr);
> > +
> > + p_jpeg.raw_data_in = TRUE;
> > + p_jpeg.do_fancy_downsampling = FALSE;
> > +
> > + jpeg_set_quality(&p_jpeg, p_sys->i_quality, TRUE);
> > +
> > + jpeg_start_compress(&p_jpeg, TRUE);
> > +
>
> This should be done in Open, then you don't even need to store i_quality
> and
> both modules can use the same context.
What will happen if some of jpeg_* functions in Open will call
user_error_exit?
Or what will happen if jpeg_destroy_decompress will call user_error_exit in
CloseDecoder?
Where will it longjmp?
--
Maxim Bublis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20140128/8039ca78/attachment.html>
More information about the vlc-devel
mailing list