[vlc-devel] [PATCH] codec: jpeg encoder implemented

Jean-Baptiste Kempf jb at videolan.org
Fri Jan 24 16:47:17 CET 2014


On 24 Jan, Maxim Bublis wrote :
> This patch implements jpeg encoder using libjpeg.

> +/* JPEG_SYS_COMMON_MEMBERS:
> + * members common to encoder and decoder descriptors
> + */
> +#define JPEG_SYS_COMMON_MEMBERS                             \
> +/**@{*/                                                     \
> +    /* libjpeg error handler manager */                     \
> +    struct jpeg_error_mgr err;                              \
> +                                                            \
> +    /* setjmp buffer for internal libjpeg error handling */ \
> +    jmp_buf setjmp_buffer;                                  \
> +                                                            \
> +    vlc_object_t *p_obj;                                    \
> +                                                            \
> +/**@}*/                                                     \
> +
>  /*
>   * jpeg decoder descriptor
>   */
>  struct decoder_sys_t
>  {
> -    /* libjpeg error handler manager */
> -    struct jpeg_error_mgr err;
> -
> -    /* setjmp buffer for internal libjpeg error handling */
> -    jmp_buf setjmp_buffer;
> -
> -    decoder_t *p_dec;
> -
> -    bool b_error;
> +    JPEG_SYS_COMMON_MEMBERS
>  };
>  
>  static int  OpenDecoder(vlc_object_t *);
> @@ -52,15 +59,39 @@ static void CloseDecoder(vlc_object_t *);
>  static picture_t *DecodeBlock(decoder_t *, block_t **);
>  
>  /*
> + * jpeg encoder descriptor
> + */
> +struct encoder_sys_t
> +{
> +    JPEG_SYS_COMMON_MEMBERS
> +};

So, both are the same?

> +#ifdef ENABLE_SOUT
> +    /* encoder submodule */
> +    add_submodule()
> +    add_shortcut("jpeg")
> +    set_section(N_("Encoding"), NULL)
> +    set_description(N_("JPEG image encoder"))
> +    set_capability("encoder", 1000)
> +    set_callbacks(OpenEncoder, CloseEncoder)
> +#endif

No quality set ?

And I wonder whether we should, or not disable-sout for images (because
it might be nice for screenshots).
> @@ -154,30 +183,12 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t **pp_block)
>      }
>  
>      jpeg_create_decompress(&p_jpeg);
> -    if (p_sys->b_error)
> -    {
> -        goto error;
> -    }
> -
>      jpeg_mem_src(&p_jpeg, p_block->p_buffer, p_block->i_buffer);
> -    if (p_sys->b_error)
> -    {
> -        goto error;
> -    }
> -
>      jpeg_read_header(&p_jpeg, TRUE);
> -    if (p_sys->b_error)
> -    {
> -        goto error;
> -    }
>  
>      p_jpeg.out_color_space = JCS_RGB;
>  
>      jpeg_start_decompress(&p_jpeg);
> -    if (p_sys->b_error)
> -    {
> -        goto error;
> -    }
>  
>      /* Set output properties */
>      p_dec->fmt_out.i_codec = VLC_CODEC_RGB24;
> @@ -210,10 +221,6 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t **pp_block)
>      {
>          jpeg_read_scanlines(&p_jpeg, p_row_pointers + p_jpeg.output_scanline,
>                                       p_jpeg.output_height - p_jpeg.output_scanline);
> -        if (p_sys->b_error)
> -        {
> -            goto error;
> -        }
>      }
>  

Why removing all this code?


The rest looks good.

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device



More information about the vlc-devel mailing list