[FFmpeg-devel] [PATCH 2/3] lavc: fix recoded subtitles end.

Clément Bœsch ubitux at gmail.com
Sun Apr 7 12:18:50 CEST 2013


On Sun, Apr 07, 2013 at 10:23:45AM +0200, Nicolas George wrote:
> Text subtitles packets are not 0-terminated (and if they are,
> it is handled by the recoding process since 0 is a valid
> Unicode code point). The terminating 0 would overwrite the
> last payload octet.
> 
> OTOH, packets must be 0-padded.
> 
> Fix a problem reported in trac ticket #2431.
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavcodec/utils.c         |    2 +-
>  tests/ref/fate/sub-charenc |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> 
> The FATE ref change is actually an enhancement: the old version corresponds
> to a file with a few broken or missing characters at the end of lines.
> 
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 76f7e8e..e4ea325 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -2185,7 +2185,7 @@ static int recode_subtitle(AVCodecContext *avctx,
>          goto end;
>      }
>      outpkt->size -= outl;
> -    outpkt->data[outpkt->size - 1] = '\0';
> +    memset(outpkt->data + outpkt->size, 0, outl);
>  

Wouldn't if (outl) outpkt->data[outpkt->size] = '\0' enough to fix the
problem? The memset looks overkill. (note: if !outl, the zeroed padding
takes care of the ending).

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130407/95c797bb/attachment.asc>


More information about the ffmpeg-devel mailing list