Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix frag_index.current out of sync
@ 2022-07-30 17:14 Zhao Zhili
  2022-07-31  0:26 ` Steven Liu
  2022-08-11  7:06 ` "zhilizhao(赵志立)"
  0 siblings, 2 replies; 5+ messages in thread
From: Zhao Zhili @ 2022-07-30 17:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Zhao Zhili

From: Zhao Zhili <zhilizhao@tencent.com>

frag_index.current is used by cenc_filter, and is updated inside
mov_read_moof. It can out of sync regarding to mov_read_packet.

Partly fix ticket #9807.
---
 libavformat/mov.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a09a762d91..ce12a9e4f1 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7095,6 +7095,31 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s
     }
 }
 
+static MOVFragmentStreamInfo *get_frag_stream_info_from_pkt(MOVFragmentIndex *frag_index, AVPacket *pkt, int id)
+{
+    int current = frag_index->current;
+
+    if (!frag_index->nb_items)
+        return NULL;
+
+    // Check frag_index->current is the right one for pkt. It can out of sync.
+    if (current >= 0 && current < frag_index->nb_items) {
+        if (frag_index->item[current].moof_offset < pkt->pos &&
+            (current + 1 == frag_index->nb_items ||
+             frag_index->item[current + 1].moof_offset > pkt->pos))
+            return get_frag_stream_info(frag_index, current, id);
+    }
+
+
+    for (int i = 0; i < frag_index->nb_items; i++) {
+        if (frag_index->item[i].moof_offset > pkt->pos)
+            break;
+        current = i;
+    }
+    frag_index->current = current;
+    return get_frag_stream_info(frag_index, current, id);
+}
+
 static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPacket *pkt, int current_index)
 {
     MOVFragmentStreamInfo *frag_stream_info;
@@ -7102,7 +7127,7 @@ static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPa
     AVEncryptionInfo *encrypted_sample;
     int encrypted_index, ret;
 
-    frag_stream_info = get_frag_stream_info(&mov->frag_index, mov->frag_index.current, st->id);
+    frag_stream_info = get_frag_stream_info_from_pkt(&mov->frag_index, pkt, st->id);
     encrypted_index = current_index;
     encryption_index = NULL;
     if (frag_stream_info) {
-- 
2.34.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix frag_index.current out of sync
  2022-07-30 17:14 [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix frag_index.current out of sync Zhao Zhili
@ 2022-07-31  0:26 ` Steven Liu
  2022-08-11  7:06 ` "zhilizhao(赵志立)"
  1 sibling, 0 replies; 5+ messages in thread
From: Steven Liu @ 2022-07-31  0:26 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Zhao Zhili

Zhao Zhili <quinkblack@foxmail.com>于2022年7月31日 周日01:15写道:

> From: Zhao Zhili <zhilizhao@tencent.com>
>
> frag_index.current is used by cenc_filter, and is updated inside
> mov_read_moof. It can out of sync regarding to mov_read_packet.
>
> Partly fix ticket #9807.
> ---
>  libavformat/mov.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index a09a762d91..ce12a9e4f1 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -7095,6 +7095,31 @@ static int cenc_decrypt(MOVContext *c,
> MOVStreamContext *sc, AVEncryptionInfo *s
>      }
>  }
>
> +static MOVFragmentStreamInfo
> *get_frag_stream_info_from_pkt(MOVFragmentIndex *frag_index, AVPacket *pkt,
> int id)
> +{
> +    int current = frag_index->current;
> +
> +    if (!frag_index->nb_items)
> +        return NULL;
> +
> +    // Check frag_index->current is the right one for pkt. It can out of
> sync.
> +    if (current >= 0 && current < frag_index->nb_items) {
> +        if (frag_index->item[current].moof_offset < pkt->pos &&
> +            (current + 1 == frag_index->nb_items ||
> +             frag_index->item[current + 1].moof_offset > pkt->pos))
> +            return get_frag_stream_info(frag_index, current, id);
> +    }
> +
> +
> +    for (int i = 0; i < frag_index->nb_items; i++) {
> +        if (frag_index->item[i].moof_offset > pkt->pos)
> +            break;
> +        current = i;
> +    }
> +    frag_index->current = current;
> +    return get_frag_stream_info(frag_index, current, id);
> +}
> +
>  static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext
> *sc, AVPacket *pkt, int current_index)
>  {
>      MOVFragmentStreamInfo *frag_stream_info;
> @@ -7102,7 +7127,7 @@ static int cenc_filter(MOVContext *mov, AVStream*
> st, MOVStreamContext *sc, AVPa
>      AVEncryptionInfo *encrypted_sample;
>      int encrypted_index, ret;
>
> -    frag_stream_info = get_frag_stream_info(&mov->frag_index,
> mov->frag_index.current, st->id);
> +    frag_stream_info = get_frag_stream_info_from_pkt(&mov->frag_index,
> pkt, st->id);
>      encrypted_index = current_index;
>      encryption_index = NULL;
>      if (frag_stream_info) {
> --
> 2.34.1
>

https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=7071

What about this patch to fix this ticket?

>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix frag_index.current out of sync
  2022-07-30 17:14 [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix frag_index.current out of sync Zhao Zhili
  2022-07-31  0:26 ` Steven Liu
@ 2022-08-11  7:06 ` "zhilizhao(赵志立)"
  2022-08-11  7:56   ` Steven Liu
  1 sibling, 1 reply; 5+ messages in thread
From: "zhilizhao(赵志立)" @ 2022-08-11  7:06 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: nachiket.programmer



> On Jul 31, 2022, at 1:14 AM, Zhao Zhili <quinkblack@foxmail.com> wrote:
> 
> From: Zhao Zhili <zhilizhao@tencent.com>
> 
> frag_index.current is used by cenc_filter, and is updated inside
> mov_read_moof. It can out of sync regarding to mov_read_packet.
> 
> Partly fix ticket #9807.
> ---
> libavformat/mov.c | 27 ++++++++++++++++++++++++++-
> 1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index a09a762d91..ce12a9e4f1 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -7095,6 +7095,31 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s
>     }
> }


Ping for review.

By the way, there is a fate failure on patchwork which is unlikely
introduced by this patchset (It happened on another patch before).
So how to make patchwork rerun the fate test without resending the
patch again?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix frag_index.current out of sync
  2022-08-11  7:06 ` "zhilizhao(赵志立)"
@ 2022-08-11  7:56   ` Steven Liu
  2022-08-16  3:34     ` "zhilizhao(赵志立)"
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Liu @ 2022-08-11  7:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: nachiket.programmer

"zhilizhao(赵志立)" <quinkblack@foxmail.com> 于2022年8月11日周四 15:07写道:
>
>
>
> > On Jul 31, 2022, at 1:14 AM, Zhao Zhili <quinkblack@foxmail.com> wrote:
> >
> > From: Zhao Zhili <zhilizhao@tencent.com>
> >
> > frag_index.current is used by cenc_filter, and is updated inside
> > mov_read_moof. It can out of sync regarding to mov_read_packet.
> >
> > Partly fix ticket #9807.
> > ---
> > libavformat/mov.c | 27 ++++++++++++++++++++++++++-
> > 1 file changed, 26 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index a09a762d91..ce12a9e4f1 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -7095,6 +7095,31 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s
> >     }
> > }
>
>
> Ping for review.
>
looks ok to me.

> By the way, there is a fate failure on patchwork which is unlikely
> introduced by this patchset (It happened on another patch before).
> So how to make patchwork rerun the fate test without resending the
> patch again?
make again to test by fate :D
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix frag_index.current out of sync
  2022-08-11  7:56   ` Steven Liu
@ 2022-08-16  3:34     ` "zhilizhao(赵志立)"
  0 siblings, 0 replies; 5+ messages in thread
From: "zhilizhao(赵志立)" @ 2022-08-16  3:34 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> On Aug 11, 2022, at 3:56 PM, Steven Liu <lingjiujianke@gmail.com> wrote:
> 
> "zhilizhao(赵志立)" <quinkblack@foxmail.com> 于2022年8月11日周四 15:07写道:
>> 
>> 
>> 
>>> On Jul 31, 2022, at 1:14 AM, Zhao Zhili <quinkblack@foxmail.com> wrote:
>>> 
>>> From: Zhao Zhili <zhilizhao@tencent.com>
>>> 
>>> frag_index.current is used by cenc_filter, and is updated inside
>>> mov_read_moof. It can out of sync regarding to mov_read_packet.
>>> 
>>> Partly fix ticket #9807.
>>> ---
>>> libavformat/mov.c | 27 ++++++++++++++++++++++++++-
>>> 1 file changed, 26 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>>> index a09a762d91..ce12a9e4f1 100644
>>> --- a/libavformat/mov.c
>>> +++ b/libavformat/mov.c
>>> @@ -7095,6 +7095,31 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s
>>>    }
>>> }
>> 
>> 
>> Ping for review.
>> 
> looks ok to me.
> 

Thanks, applied as 98dcdd18 and 1af7797d212.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-16  3:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-30 17:14 [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix frag_index.current out of sync Zhao Zhili
2022-07-31  0:26 ` Steven Liu
2022-08-11  7:06 ` "zhilizhao(赵志立)"
2022-08-11  7:56   ` Steven Liu
2022-08-16  3:34     ` "zhilizhao(赵志立)"

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git