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.

Attachment: pgpwkf2saGh2F.pgp
Description: PGP signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to