[FFmpeg-devel] [PATCH 2/3] textdec: Rename all generic parts from srt to text.

Nicolas George nicolas.george at normalesup.org
Wed Aug 1 18:51:02 CEST 2012


Le quintidi 15 thermidor, an CCXX, Philip Langdale a écrit :
> +static const char *text_to_ass(AVCodecContext *avctx, char *out, char *out_end,
> +                               const char *in, int x1, int y1, int x2, int y2)
>  {
>      char c, *param, buffer[128], tmp[128];
>      int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
> -    SrtStack stack[16];
> +    TagStack stack[16];
>  
>      stack[0].tag[0] = 0;
>      strcpy(stack[0].param[PARAM_SIZE],  "{\\fs}");
> @@ -204,8 +204,8 @@ static const char *read_ts(const char *buf, int *ts_start, int *ts_end,
>      return NULL;
>  }

This is not really text -> ass. It could be called "pseudohtml_to_ass"

>  
> -static int srt_decode_frame(AVCodecContext *avctx,
> -                            void *data, int *got_sub_ptr, AVPacket *avpkt)
> +static int text_decode_frame(AVCodecContext *avctx,
> +                             void *data, int *got_sub_ptr, AVPacket *avpkt)
>  {
>      AVSubtitle *sub = data;
>      int ts_start, ts_end, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
> @@ -220,8 +220,8 @@ static int srt_decode_frame(AVCodecContext *avctx,
>          ptr = read_ts(ptr, &ts_start, &ts_end, &x1, &y1, &x2, &y2);
>          if (!ptr)
>              break;
> -        ptr = srt_to_ass(avctx, buffer, buffer+sizeof(buffer), ptr,
> -                         x1, y1, x2, y2);
> +        ptr = text_to_ass(avctx, buffer, buffer+sizeof(buffer), ptr,
> +                          x1, y1, x2, y2);

After some thought, I am not comfortable with that. If the codec is text, it
should have nothing to do with ASS, especially since ASS is still a mess of
temporary hacks.

>          ff_ass_add_rect(sub, buffer, ts_start, ts_end-ts_start, 0);
>      }
>  
> @@ -235,5 +235,5 @@ AVCodec ff_srt_decoder = {
>      .type         = AVMEDIA_TYPE_SUBTITLE,
>      .id           = CODEC_ID_SRT,
>      .init         = ff_ass_subtitle_header_default,
> -    .decode       = srt_decode_frame,
> +    .decode       = text_decode_frame,
>  };

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120801/f501f87e/attachment.asc>


More information about the ffmpeg-devel mailing list