diff mbox

[FFmpeg-devel,1/3] decklink: add fourCC of display mode to list_format output

Message ID 1489673161-18533-2-git-send-email-atze@fem.tu-ilmenau.de
State Superseded
Headers show

Commit Message

Matthias Hunstock March 16, 2017, 2:05 p.m. UTC
---
 libavdevice/decklink_common.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Marton Balint March 16, 2017, 7:55 p.m. UTC | #1
On Thu, 16 Mar 2017, Matthias Hunstock wrote:

> ---
> libavdevice/decklink_common.cpp | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
> index 8b499c5..131d186 100644
> --- a/libavdevice/decklink_common.cpp
> +++ b/libavdevice/decklink_common.cpp
> @@ -276,6 +276,7 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct
>     struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>     IDeckLinkDisplayModeIterator *itermode;
>     IDeckLinkDisplayMode *mode;
> +    char fourcc[32];
>     int i=0;
>     HRESULT res;
> 
> @@ -297,13 +298,15 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct
>             return AVERROR(EIO);
>     }
> 
> -    av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n",
> +    av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n\tmode\tfourCC\tdescription",
>                avctx->filename);
>     while (itermode->Next(&mode) == S_OK) {
>         BMDTimeValue tb_num, tb_den;
>         mode->GetFrameRate(&tb_num, &tb_den);
> -        av_log(avctx, AV_LOG_INFO, "\t%d\t%ldx%ld at %d/%d fps",
> -                ++i,mode->GetWidth(), mode->GetHeight(),
> +        av_get_codec_tag_string(fourcc, sizeof(fourcc), mode->GetDisplayMode());
> +        av_log(avctx, AV_LOG_INFO, "\n\t%d\t%c%c%c%c\t%ldx%ld at %d/%d fps",
> +                ++i, fourcc[3], fourcc[2], fourcc[1], fourcc[0],
> +                mode->GetWidth(), mode->GetHeight(),

fourcc is a string, is there a reason why you don't simply print it 
using "%s"?

>                 (int) tb_den, (int) tb_num);
>         switch (mode->GetFieldDominance()) {
>         case bmdLowerFieldFirst:
> @@ -311,9 +314,9 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct
>         case bmdUpperFieldFirst:
>         av_log(avctx, AV_LOG_INFO, " (interlaced, upper field first)"); break;
>         }
> -        av_log(avctx, AV_LOG_INFO, "\n");
>         mode->Release();
>     }
> +    av_log(avctx, AV_LOG_INFO, "\n");
>
>     itermode->Release();
>

Regards,
Marton
Matthias Hunstock March 16, 2017, 9:38 p.m. UTC | #2
Am 16.03.2017 um 20:55 schrieb Marton Balint:
> 
> 
> On Thu, 16 Mar 2017, Matthias Hunstock wrote:
> 
>> ---
>> libavdevice/decklink_common.cpp | 11 +++++++----
>> 1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavdevice/decklink_common.cpp
>> b/libavdevice/decklink_common.cpp
>> index 8b499c5..131d186 100644
>> --- a/libavdevice/decklink_common.cpp
>> +++ b/libavdevice/decklink_common.cpp
>> @@ -276,6 +276,7 @@ int ff_decklink_list_formats(AVFormatContext
>> *avctx, decklink_direction_t direct
>>     struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>>     IDeckLinkDisplayModeIterator *itermode;
>>     IDeckLinkDisplayMode *mode;
>> +    char fourcc[32];
>>     int i=0;
>>     HRESULT res;
>>
>> @@ -297,13 +298,15 @@ int ff_decklink_list_formats(AVFormatContext
>> *avctx, decklink_direction_t direct
>>             return AVERROR(EIO);
>>     }
>>
>> -    av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n",
>> +    av_log(avctx, AV_LOG_INFO, "Supported formats for
>> '%s':\n\tmode\tfourCC\tdescription",
>>                avctx->filename);
>>     while (itermode->Next(&mode) == S_OK) {
>>         BMDTimeValue tb_num, tb_den;
>>         mode->GetFrameRate(&tb_num, &tb_den);
>> -        av_log(avctx, AV_LOG_INFO, "\t%d\t%ldx%ld at %d/%d fps",
>> -                ++i,mode->GetWidth(), mode->GetHeight(),
>> +        av_get_codec_tag_string(fourcc, sizeof(fourcc),
>> mode->GetDisplayMode());
>> +        av_log(avctx, AV_LOG_INFO, "\n\t%d\t%c%c%c%c\t%ldx%ld at
>> %d/%d fps",
>> +                ++i, fourcc[3], fourcc[2], fourcc[1], fourcc[0],
>> +                mode->GetWidth(), mode->GetHeight(),
> 
> fourcc is a string, is there a reason why you don't simply print it
> using "%s"?

Yes, unfortunately the order is reversed then, and I considered 'cstn'
or '05iH' harder to remember and use than 'ntsc' or 'Hi50'. Did not find
any util function that does the fourCC conversion in that reverse order.

Matthias
Marton Balint March 16, 2017, 9:55 p.m. UTC | #3
On Thu, 16 Mar 2017, Matthias Hunstock wrote:

> Am 16.03.2017 um 20:55 schrieb Marton Balint:
>> 
>> 
>> On Thu, 16 Mar 2017, Matthias Hunstock wrote:
>> 
>>> ---
>>> libavdevice/decklink_common.cpp | 11 +++++++----
>>> 1 file changed, 7 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/libavdevice/decklink_common.cpp
>>> b/libavdevice/decklink_common.cpp
>>> index 8b499c5..131d186 100644
>>> --- a/libavdevice/decklink_common.cpp
>>> +++ b/libavdevice/decklink_common.cpp
>>> @@ -276,6 +276,7 @@ int ff_decklink_list_formats(AVFormatContext
>>> *avctx, decklink_direction_t direct
>>>     struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>>>     IDeckLinkDisplayModeIterator *itermode;
>>>     IDeckLinkDisplayMode *mode;
>>> +    char fourcc[32];
>>>     int i=0;
>>>     HRESULT res;
>>>
>>> @@ -297,13 +298,15 @@ int ff_decklink_list_formats(AVFormatContext
>>> *avctx, decklink_direction_t direct
>>>             return AVERROR(EIO);
>>>     }
>>>
>>> -    av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n",
>>> +    av_log(avctx, AV_LOG_INFO, "Supported formats for
>>> '%s':\n\tmode\tfourCC\tdescription",
>>>                avctx->filename);
>>>     while (itermode->Next(&mode) == S_OK) {
>>>         BMDTimeValue tb_num, tb_den;
>>>         mode->GetFrameRate(&tb_num, &tb_den);
>>> -        av_log(avctx, AV_LOG_INFO, "\t%d\t%ldx%ld at %d/%d fps",
>>> -                ++i,mode->GetWidth(), mode->GetHeight(),
>>> +        av_get_codec_tag_string(fourcc, sizeof(fourcc),
>>> mode->GetDisplayMode());
>>> +        av_log(avctx, AV_LOG_INFO, "\n\t%d\t%c%c%c%c\t%ldx%ld at
>>> %d/%d fps",
>>> +                ++i, fourcc[3], fourcc[2], fourcc[1], fourcc[0],
>>> +                mode->GetWidth(), mode->GetHeight(),
>> 
>> fourcc is a string, is there a reason why you don't simply print it
>> using "%s"?
>
> Yes, unfortunately the order is reversed then, and I considered 'cstn'
> or '05iH' harder to remember and use than 'ntsc' or 'Hi50'. Did not find
> any util function that does the fourCC conversion in that reverse order.
>

Oh, I see. Maybe you can use av_bswap32 to transform the BMDDisplayMode to 
the proper byte order before transfroming it to fourcc string.

Regards,
Marton
diff mbox

Patch

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index 8b499c5..131d186 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -276,6 +276,7 @@  int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct
     struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
     IDeckLinkDisplayModeIterator *itermode;
     IDeckLinkDisplayMode *mode;
+    char fourcc[32];
     int i=0;
     HRESULT res;
 
@@ -297,13 +298,15 @@  int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct
             return AVERROR(EIO);
     }
 
-    av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n",
+    av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n\tmode\tfourCC\tdescription",
                avctx->filename);
     while (itermode->Next(&mode) == S_OK) {
         BMDTimeValue tb_num, tb_den;
         mode->GetFrameRate(&tb_num, &tb_den);
-        av_log(avctx, AV_LOG_INFO, "\t%d\t%ldx%ld at %d/%d fps",
-                ++i,mode->GetWidth(), mode->GetHeight(),
+        av_get_codec_tag_string(fourcc, sizeof(fourcc), mode->GetDisplayMode());
+        av_log(avctx, AV_LOG_INFO, "\n\t%d\t%c%c%c%c\t%ldx%ld at %d/%d fps",
+                ++i, fourcc[3], fourcc[2], fourcc[1], fourcc[0],
+                mode->GetWidth(), mode->GetHeight(),
                 (int) tb_den, (int) tb_num);
         switch (mode->GetFieldDominance()) {
         case bmdLowerFieldFirst:
@@ -311,9 +314,9 @@  int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct
         case bmdUpperFieldFirst:
         av_log(avctx, AV_LOG_INFO, " (interlaced, upper field first)"); break;
         }
-        av_log(avctx, AV_LOG_INFO, "\n");
         mode->Release();
     }
+    av_log(avctx, AV_LOG_INFO, "\n");
 
     itermode->Release();