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] avformat/mov: skip call ff_codec_get_id if possible
@ 2022-04-19  5:12 Zhao Zhili
  2022-04-29  9:46 ` "zhilizhao(赵志立)"
  0 siblings, 1 reply; 3+ messages in thread
From: Zhao Zhili @ 2022-04-19  5:12 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Zhao Zhili

ff_codec_get_id loops over ff_codec_movvideo_tags (which is a large
array) two times. The result is unused most of the cases.
---
 libavformat/mov.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6c847de164..bdc8c84bae 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2487,8 +2487,6 @@ static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb,
                                   int codec_tag, int format,
                                   int64_t size)
 {
-    int video_codec_id = ff_codec_get_id(ff_codec_movvideo_tags, format);
-
     if (codec_tag &&
          (codec_tag != format &&
           // AVID 1:1 samples with differing data format and codec tag exist
@@ -2497,7 +2495,7 @@ static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb,
           codec_tag != AV_RL32("apcn") && codec_tag != AV_RL32("apch") &&
           // so is dv (sigh)
           codec_tag != AV_RL32("dvpp") && codec_tag != AV_RL32("dvcp") &&
-          (c->fc->video_codec_id ? video_codec_id != c->fc->video_codec_id
+          (c->fc->video_codec_id ? ff_codec_get_id(ff_codec_movvideo_tags, format) != c->fc->video_codec_id
                                  : codec_tag != MKTAG('j','p','e','g')))) {
         /* Multiple fourcc, we skip JPEG. This is not correct, we should
          * export it as a separate AVStream but this needs a few changes
-- 
2.35.3

_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/mov: skip call ff_codec_get_id if possible
  2022-04-19  5:12 [FFmpeg-devel] [PATCH] avformat/mov: skip call ff_codec_get_id if possible Zhao Zhili
@ 2022-04-29  9:46 ` "zhilizhao(赵志立)"
  2022-04-29 11:26   ` Andreas Rheinhardt
  0 siblings, 1 reply; 3+ messages in thread
From: "zhilizhao(赵志立)" @ 2022-04-29  9:46 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> On Apr 19, 2022, at 1:12 PM, Zhao Zhili <quinkblack@foxmail.com> wrote:
> 
> ff_codec_get_id loops over ff_codec_movvideo_tags (which is a large
> array) two times. The result is unused most of the cases.
> ---
> libavformat/mov.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 6c847de164..bdc8c84bae 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2487,8 +2487,6 @@ static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb,
>                                   int codec_tag, int format,
>                                   int64_t size)
> {
> -    int video_codec_id = ff_codec_get_id(ff_codec_movvideo_tags, format);
> -
>     if (codec_tag &&
>          (codec_tag != format &&
>           // AVID 1:1 samples with differing data format and codec tag exist
> @@ -2497,7 +2495,7 @@ static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb,
>           codec_tag != AV_RL32("apcn") && codec_tag != AV_RL32("apch") &&
>           // so is dv (sigh)
>           codec_tag != AV_RL32("dvpp") && codec_tag != AV_RL32("dvcp") &&
> -          (c->fc->video_codec_id ? video_codec_id != c->fc->video_codec_id
> +          (c->fc->video_codec_id ? ff_codec_get_id(ff_codec_movvideo_tags, format) != c->fc->video_codec_id
>                                  : codec_tag != MKTAG('j','p','e','g')))) {
>         /* Multiple fourcc, we skip JPEG. This is not correct, we should
>          * export it as a separate AVStream but this needs a few changes
> -- 
> 2.35.3
> 

Do we care about such micro-optimization, or just let compiler do it’s job?
_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/mov: skip call ff_codec_get_id if possible
  2022-04-29  9:46 ` "zhilizhao(赵志立)"
@ 2022-04-29 11:26   ` Andreas Rheinhardt
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2022-04-29 11:26 UTC (permalink / raw)
  To: ffmpeg-devel

"zhilizhao(赵志立)":
> 
> 
>> On Apr 19, 2022, at 1:12 PM, Zhao Zhili <quinkblack@foxmail.com> wrote:
>>
>> ff_codec_get_id loops over ff_codec_movvideo_tags (which is a large
>> array) two times. The result is unused most of the cases.
>> ---
>> libavformat/mov.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index 6c847de164..bdc8c84bae 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -2487,8 +2487,6 @@ static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb,
>>                                   int codec_tag, int format,
>>                                   int64_t size)
>> {
>> -    int video_codec_id = ff_codec_get_id(ff_codec_movvideo_tags, format);
>> -
>>     if (codec_tag &&
>>          (codec_tag != format &&
>>           // AVID 1:1 samples with differing data format and codec tag exist
>> @@ -2497,7 +2495,7 @@ static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb,
>>           codec_tag != AV_RL32("apcn") && codec_tag != AV_RL32("apch") &&
>>           // so is dv (sigh)
>>           codec_tag != AV_RL32("dvpp") && codec_tag != AV_RL32("dvcp") &&
>> -          (c->fc->video_codec_id ? video_codec_id != c->fc->video_codec_id
>> +          (c->fc->video_codec_id ? ff_codec_get_id(ff_codec_movvideo_tags, format) != c->fc->video_codec_id
>>                                  : codec_tag != MKTAG('j','p','e','g')))) {
>>         /* Multiple fourcc, we skip JPEG. This is not correct, we should
>>          * export it as a separate AVStream but this needs a few changes
>> -- 
>> 2.35.3
>>
> 
> Do we care about such micro-optimization, or just let compiler do it’s job?

A compiler could currently only optimize this on its own if you were
using LTO; it might also be able to optimize this if ff_codec_get_id
were marked as av_pure. Of course, there is no guarantee that this is
optimized in these cases, but you could check whether e.g. GCC/Clang do it.
And I don't see anything wrong with micro-optimizations.

- Andreas
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2022-04-29 11:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19  5:12 [FFmpeg-devel] [PATCH] avformat/mov: skip call ff_codec_get_id if possible Zhao Zhili
2022-04-29  9:46 ` "zhilizhao(赵志立)"
2022-04-29 11:26   ` Andreas Rheinhardt

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