<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">> +}<br></div></div><div class="im">

> +<br>
> +static block_t *EncodeBlock(encoder_t *p_enc, picture_t *p_pic)<br>
> +{<br>
> +    encoder_sys_t *p_sys = p_enc->p_sys;<br>
> +<br>
> +    const int bytesPerPixel = p_enc->fmt_out.video.i_bits_per_pixel ?<br>
> +                                p_enc->fmt_out.video.i_bits_per_pixel / 8 : 3;<br>
<br>
</div>You should rather set *input* video format in Open<br>
<div><div class="h5"><br>
> +    const int blocksize = bytesPerPixel * p_enc->fmt_in.video.i_visible_width * p_enc->fmt_in.video.i_visible_height;<br>
> +<br>
> +    block_t *p_block = block_Alloc(blocksize);<br>
> +    if (p_block == NULL)<br>
> +    {<br>
> +        return NULL;<br>
> +    }<br>
> +<br>
> +    struct jpeg_compress_struct p_jpeg;<br>
> +    JSAMPIMAGE p_row_pointers = NULL;<br>
> +<br>
> +    p_jpeg.err = jpeg_std_error(&p_sys->err);<br>
> +    p_sys->err.error_exit = encoder_error_exit;<br>
> +    p_sys->err.output_message = encoder_error_message;<br>
> +<br>
> +    /* libjpeg longjmp's there in case of error */<br>
> +    if (setjmp(p_sys->setjmp_buffer))<br>
> +    {<br>
> +        goto error;<br>
> +    }<br>
> +<br>
> +    jpeg_create_compress(&p_jpeg);<br>
> +    jpeg_mem_dest(&p_jpeg, &p_block->p_buffer, &p_block->i_buffer);<br>
> +<br>
> +    p_jpeg.image_width = p_enc->fmt_in.video.i_visible_width;<br>
> +    p_jpeg.image_height = p_enc->fmt_in.video.i_visible_height;<br>
> +    p_jpeg.input_components = bytesPerPixel;<br>
> +    p_jpeg.in_color_space = JCS_YCbCr;<br>
> +<br>
> +    jpeg_set_defaults(&p_jpeg);<br>
> +    jpeg_set_colorspace(&p_jpeg, JCS_YCbCr);<br>
> +<br>
> +    p_jpeg.raw_data_in = TRUE;<br>
> +    p_jpeg.do_fancy_downsampling = FALSE;<br>
> +<br>
> +    jpeg_set_quality(&p_jpeg, p_sys->i_quality, TRUE);<br>
> +<br>
> +    jpeg_start_compress(&p_jpeg, TRUE);<br>
> +<br>
<br>
</div></div>This should be done in Open, then you don't even need to store i_quality and<br>
both modules can use the same context.</blockquote></div><div class="gmail_extra"><br></div>What will happen if some of jpeg_* functions in Open will call user_error_exit?</div><div class="gmail_extra">Or what will happen if jpeg_destroy_decompress will call user_error_exit in CloseDecoder?</div>
<div class="gmail_extra">Where will it longjmp?</div><div class="gmail_extra"><div><br></div>-- <br>Maxim Bublis
</div></div>