[FFmpeg-devel] [RFC]Print a warning if a subtitle demuxer changes utf16 to utf8.

Clément Bœsch u at pkh.me
Tue Oct 28 09:56:28 CET 2014


On Tue, Oct 28, 2014 at 08:35:12AM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> The user should be told by libavformat if it does something unexpected.
> Related to ticket #4059.
> 
> Please comment, Carl Eugen

[...]
> -void ff_text_init_avio(FFTextReader *r, AVIOContext *pb)
> +void ff_text_init_avio(AVFormatContext *s, FFTextReader *r, AVIOContext *pb)
>  {
>      int i;
>      r->pb = pb;
> @@ -45,13 +45,16 @@ void ff_text_init_avio(FFTextReader *r, AVIOContext *pb)
>              r->buf_pos += 3;
>          }
>      }
> +    if (s && (r->type == FF_UTF16LE || r->type == FF_UTF16BE))
> +        av_log(s, AV_LOG_WARNING,
> +               "UTF16 is automatically converted to UTF8, do not specify a character encoding\n");

av_log() accepts a NULL pointer, this is confusing: you don't want to warn
when there is no log context?

>  }
>  
>  void ff_text_init_buf(FFTextReader *r, void *buf, size_t size)
>  {
>      memset(&r->buf_pb, 0, sizeof(r->buf_pb));
>      ffio_init_context(&r->buf_pb, buf, size, 0, NULL, NULL, NULL, NULL);
> -    ff_text_init_avio(r, &r->buf_pb);
> +    ff_text_init_avio(NULL, r, &r->buf_pb);
>  }
>  
>  int64_t ff_text_pos(FFTextReader *r)
> diff --git a/libavformat/subtitles.h b/libavformat/subtitles.h
> index 903c24d..c549584 100644
> --- a/libavformat/subtitles.h
> +++ b/libavformat/subtitles.h
> @@ -53,10 +53,11 @@ typedef struct {
>   * The purpose of FFTextReader is to transparently convert read data to UTF-8
>   * if the stream had a UTF-16 BOM.
>   *
> + * @param s AVFormatContext to provide av_log context
>   * @param r object which will be initialized
>   * @param pb stream to read from (referenced as long as FFTextReader is in use)
>   */
> -void ff_text_init_avio(FFTextReader *r, AVIOContext *pb);
> +void ff_text_init_avio(AVFormatContext *s, FFTextReader *r, AVIOContext *pb);

If you want to use it only for logging, make it void*

[...]

Not commenting on the patch itself.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141028/805220f4/attachment.asc>


More information about the ffmpeg-devel mailing list