diff mbox

[FFmpeg-devel] avformat/libopenmpt: Query duration and metadata after selecting subsong

Message ID 1505655350-25301-1-git-send-email-osmanx@problemloesungsmaschine.de
State Accepted
Commit 3d2da6d585509daddcd65f206b1a262c9c78cbce
Headers show

Commit Message

Jörn Heusipp Sept. 17, 2017, 1:35 p.m. UTC
Duration depends on the selected subsong and thus must be queried after
selecting the subsong. There is no compelling reason to query other
metadata earlier either.

Signed-off-by: Jörn Heusipp <osmanx@problemloesungsmaschine.de>
---
 libavformat/libopenmpt.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Comments

Reino Wijnsma Sept. 17, 2017, 3:54 p.m. UTC | #1
On 17-9-2017 15:35, Jörn Heusipp <osmanx@problemloesungsmaschine.de> wrote:
> Duration depends on the selected subsong and thus must be queried after
> selecting the subsong. There is no compelling reason to query other
> metadata earlier either.
>
> Signed-off-by: Jörn Heusipp <osmanx@problemloesungsmaschine.de>
> ---
>  libavformat/libopenmpt.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c
> index a7e3859..af6eb1a 100644
> --- a/libavformat/libopenmpt.c
> +++ b/libavformat/libopenmpt.c
> @@ -93,14 +93,7 @@ static int read_header_openmpt(AVFormatContext *s)
>      if (!openmpt->module)
>              return AVERROR_INVALIDDATA;
>  
> -    openmpt->channels   = av_get_channel_layout_nb_channels(openmpt->layout);
> -    openmpt->duration   = openmpt_module_get_duration_seconds(openmpt->module);
> -
> -    add_meta(s, "artist",  openmpt_module_get_metadata(openmpt->module, "artist"));
> -    add_meta(s, "title",   openmpt_module_get_metadata(openmpt->module, "title"));
> -    add_meta(s, "encoder", openmpt_module_get_metadata(openmpt->module, "tracker"));
> -    add_meta(s, "comment", openmpt_module_get_metadata(openmpt->module, "message"));
> -    add_meta(s, "date",    openmpt_module_get_metadata(openmpt->module, "date"));
> +    openmpt->channels = av_get_channel_layout_nb_channels(openmpt->layout);
>  
>      if (openmpt->subsong >= openmpt_module_get_num_subsongs(openmpt->module)) {
>          openmpt_module_destroy(openmpt->module);
> @@ -120,6 +113,14 @@ static int read_header_openmpt(AVFormatContext *s)
>          }
>      }
>  
> +    openmpt->duration = openmpt_module_get_duration_seconds(openmpt->module);
> +
> +    add_meta(s, "artist",  openmpt_module_get_metadata(openmpt->module, "artist"));
> +    add_meta(s, "title",   openmpt_module_get_metadata(openmpt->module, "title"));
> +    add_meta(s, "encoder", openmpt_module_get_metadata(openmpt->module, "tracker"));
> +    add_meta(s, "comment", openmpt_module_get_metadata(openmpt->module, "message"));
> +    add_meta(s, "date",    openmpt_module_get_metadata(openmpt->module, "date"));
> +
>      st = avformat_new_stream(s, NULL);
>      if (!st) {
>          openmpt_module_destroy(openmpt->module);
I've tested your patch and I can confirm FFmpeg now correctly shows the
subsong duration.
Jörn Heusipp Sept. 24, 2017, 2:35 p.m. UTC | #2
On 09/17/2017 03:35 PM, Jörn Heusipp wrote:
> Duration depends on the selected subsong and thus must be queried after
> selecting the subsong. There is no compelling reason to query other
> metadata earlier either.
> 
> Signed-off-by: Jörn Heusipp <osmanx@problemloesungsmaschine.de>
> ---

ping?
Josh de Kock Sept. 26, 2017, 1:58 p.m. UTC | #3
On 24/09/2017 15:35, Jörn Heusipp wrote:
>
> On 09/17/2017 03:35 PM, Jörn Heusipp wrote:
>> Duration depends on the selected subsong and thus must be queried after
>> selecting the subsong. There is no compelling reason to query other
>> metadata earlier either.
>>
>> Signed-off-by: Jörn Heusipp <osmanx@problemloesungsmaschine.de>
>> ---
>
> ping?

This looks fine I've tested with latest libopenmpt. Pushed.

Thanks,
diff mbox

Patch

diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c
index a7e3859..af6eb1a 100644
--- a/libavformat/libopenmpt.c
+++ b/libavformat/libopenmpt.c
@@ -93,14 +93,7 @@  static int read_header_openmpt(AVFormatContext *s)
     if (!openmpt->module)
             return AVERROR_INVALIDDATA;
 
-    openmpt->channels   = av_get_channel_layout_nb_channels(openmpt->layout);
-    openmpt->duration   = openmpt_module_get_duration_seconds(openmpt->module);
-
-    add_meta(s, "artist",  openmpt_module_get_metadata(openmpt->module, "artist"));
-    add_meta(s, "title",   openmpt_module_get_metadata(openmpt->module, "title"));
-    add_meta(s, "encoder", openmpt_module_get_metadata(openmpt->module, "tracker"));
-    add_meta(s, "comment", openmpt_module_get_metadata(openmpt->module, "message"));
-    add_meta(s, "date",    openmpt_module_get_metadata(openmpt->module, "date"));
+    openmpt->channels = av_get_channel_layout_nb_channels(openmpt->layout);
 
     if (openmpt->subsong >= openmpt_module_get_num_subsongs(openmpt->module)) {
         openmpt_module_destroy(openmpt->module);
@@ -120,6 +113,14 @@  static int read_header_openmpt(AVFormatContext *s)
         }
     }
 
+    openmpt->duration = openmpt_module_get_duration_seconds(openmpt->module);
+
+    add_meta(s, "artist",  openmpt_module_get_metadata(openmpt->module, "artist"));
+    add_meta(s, "title",   openmpt_module_get_metadata(openmpt->module, "title"));
+    add_meta(s, "encoder", openmpt_module_get_metadata(openmpt->module, "tracker"));
+    add_meta(s, "comment", openmpt_module_get_metadata(openmpt->module, "message"));
+    add_meta(s, "date",    openmpt_module_get_metadata(openmpt->module, "date"));
+
     st = avformat_new_stream(s, NULL);
     if (!st) {
         openmpt_module_destroy(openmpt->module);