diff mbox

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

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

Commit Message

Matthias Hunstock March 17, 2017, 12:41 a.m. UTC
Signed-off-by: Matthias Hunstock <atze@fem.tu-ilmenau.de>
---
 libavdevice/decklink_common.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Marton Balint March 17, 2017, 11:25 p.m. UTC | #1
On Fri, 17 Mar 2017, Matthias Hunstock wrote:

> Signed-off-by: Matthias Hunstock <atze@fem.tu-ilmenau.de>
> ---
> 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..82b3a0c 100644
> --- a/libavdevice/decklink_common.cpp
> +++ b/libavdevice/decklink_common.cpp
> @@ -33,6 +33,7 @@ extern "C" {
> #include "libavformat/avformat.h"
> #include "libavformat/internal.h"
> #include "libavutil/imgutils.h"
> +#include "libavutil/bswap.h"
> }
> 
> #include "decklink_common.h"
> @@ -276,6 +277,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;
> +    BMDDisplayMode format_code;

Well, technically this will contain a swapped DisplayMode so maybe 
uint32_t is better here...

>     int i=0;
>     HRESULT res;
> 
> @@ -297,13 +299,14 @@ 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\tformat_code\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(),
> +        format_code = av_bswap32(mode->GetDisplayMode());
> +        av_log(avctx, AV_LOG_INFO, "\n\t%d\t%.4s\t\t%ldx%ld at %d/%d fps",
> +                ++i, (char*) &format_code, 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();
>

Otherwise it looks good.

Thanks,
Marton
diff mbox

Patch

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index 8b499c5..82b3a0c 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -33,6 +33,7 @@  extern "C" {
 #include "libavformat/avformat.h"
 #include "libavformat/internal.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/bswap.h"
 }
 
 #include "decklink_common.h"
@@ -276,6 +277,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;
+    BMDDisplayMode format_code;
     int i=0;
     HRESULT res;
 
@@ -297,13 +299,14 @@  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\tformat_code\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(),
+        format_code = av_bswap32(mode->GetDisplayMode());
+        av_log(avctx, AV_LOG_INFO, "\n\t%d\t%.4s\t\t%ldx%ld at %d/%d fps",
+                ++i, (char*) &format_code, 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();