[FFmpeg-devel] [PATCH 13/17] avformat/assdec: make sure "Comments:" events end up in the header
Clément Bœsch
u at pkh.me
Sat Sep 27 17:39:49 CEST 2014
On Sun, Sep 21, 2014 at 08:35:51AM +0200, wm4 wrote:
> On Sat, 20 Sep 2014 22:27:53 +0200
> Clément Bœsch <u at pkh.me> wrote:
>
> > ---
> > libavformat/assdec.c | 26 ++++++++------------------
> > 1 file changed, 8 insertions(+), 18 deletions(-)
> >
> > diff --git a/libavformat/assdec.c b/libavformat/assdec.c
> > index 5480171..2187c7d 100644
> > --- a/libavformat/assdec.c
> > +++ b/libavformat/assdec.c
> > @@ -104,7 +104,7 @@ static int ass_read_header(AVFormatContext *s)
> > {
> > ASSContext *ass = s->priv_data;
> > AVBPrint header, line, rline;
> > - int header_remaining, res = 0;
> > + int res = 0;
> > AVStream *st;
> > FFTextReader tr;
> > ff_text_init_avio(&tr, s->pb);
> > @@ -116,33 +116,24 @@ static int ass_read_header(AVFormatContext *s)
> > st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
> > st->codec->codec_id = AV_CODEC_ID_ASS;
> >
> > - header_remaining = INT_MAX;
> > -
> > av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED);
> > av_bprint_init(&line, 0, AV_BPRINT_SIZE_UNLIMITED);
> > av_bprint_init(&rline, 0, AV_BPRINT_SIZE_UNLIMITED);
> >
> > + // TODO reindent
> > for (;;) {
> > int64_t pos = get_line(&line, &tr);
> > -
> > - if (!line.str[0]) // EOF
> > - break;
> > -
> > - if (!memcmp(line.str, "[Events]", 8))
> > - header_remaining = 2;
> > - else if (line.str[0] == '[')
> > - header_remaining = INT_MAX;
> > -
> > - if (header_remaining) {
> > - av_bprintf(&header, "%s", line.str);
> > - header_remaining--;
> > - } else {
> > int64_t ts_start = AV_NOPTS_VALUE;
> > int duration = -1;
> > AVPacket *sub;
> >
> > - if (read_dialogue(ass, &rline, line.str, &ts_start, &duration) < 0)
> > + if (!line.str[0]) // EOF
> > + break;
>
> Does get_line() skip empty lines?
>
> > +
> > + if (read_dialogue(ass, &rline, line.str, &ts_start, &duration) < 0) {
> > + av_bprintf(&header, "%s", line.str);
> > continue;
> > + }
> > sub = ff_subtitles_queue_insert(&ass->q, rline.str, rline.len, 0);
> > if (!sub) {
> > res = AVERROR(ENOMEM);
> > @@ -151,7 +142,6 @@ static int ass_read_header(AVFormatContext *s)
> > sub->pos = pos;
> > sub->pts = ts_start;
> > sub->duration = duration;
> > - }
> > }
> >
> > av_bprint_finalize(&line, NULL);
>
> A bit "regrettable" IMO (more work for a user if a user really wants to
> get timed comments), but surely more consistent in general (and I guess
> Comment events got lost of reinterpreted as Dialogue events before
> this?).
They were in the packets previously, but were dropped while transcoding
(with errors).
Patch applied.
--
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/20140927/2688f7f5/attachment.asc>
More information about the ffmpeg-devel
mailing list