]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_showinfo.c
http: K&R formatting cosmetics
[ffmpeg] / libavfilter / vf_showinfo.c
index c89b0287d81e9da285a3e0ffdbcf9cdeff8e00b6..cf9099574b872073750c0ff5bc3504ceaf86abdc 100644 (file)
  * filter for showing textual video frame information
  */
 
+#include <inttypes.h>
+
 #include "libavutil/adler32.h"
+#include "libavutil/display.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/stereo3d.h"
+
 #include "avfilter.h"
 #include "internal.h"
 #include "video.h"
 
-typedef struct {
+typedef struct ShowInfoContext {
     unsigned int frame;
 } ShowInfoContext;
 
-static av_cold int init(AVFilterContext *ctx, const char *args)
+static void dump_stereo3d(AVFilterContext *ctx, AVFrameSideData *sd)
 {
-    ShowInfoContext *showinfo = ctx->priv;
-    showinfo->frame = 0;
-    return 0;
+    AVStereo3D *stereo;
+
+    av_log(ctx, AV_LOG_INFO, "stereoscopic information: ");
+    if (sd->size < sizeof(*stereo)) {
+        av_log(ctx, AV_LOG_INFO, "invalid data");
+        return;
+    }
+
+    stereo = (AVStereo3D *)sd->data;
+
+    av_log(ctx, AV_LOG_INFO, "type - ");
+    switch (stereo->type) {
+    case AV_STEREO3D_2D:                  av_log(ctx, AV_LOG_INFO, "2D");                     break;
+    case AV_STEREO3D_SIDEBYSIDE:          av_log(ctx, AV_LOG_INFO, "side by side");           break;
+    case AV_STEREO3D_TOPBOTTOM:           av_log(ctx, AV_LOG_INFO, "top and bottom");         break;
+    case AV_STEREO3D_FRAMESEQUENCE:       av_log(ctx, AV_LOG_INFO, "frame alternate");        break;
+    case AV_STEREO3D_CHECKERBOARD:        av_log(ctx, AV_LOG_INFO, "checkerboard");           break;
+    case AV_STEREO3D_LINES:               av_log(ctx, AV_LOG_INFO, "interleaved lines");      break;
+    case AV_STEREO3D_COLUMNS:             av_log(ctx, AV_LOG_INFO, "interleaved columns");    break;
+    case AV_STEREO3D_SIDEBYSIDE_QUINCUNX: av_log(ctx, AV_LOG_INFO, "side by side "
+                                                                   "(quincunx subsampling)"); break;
+    default:                              av_log(ctx, AV_LOG_WARNING, "unknown");             break;
+    }
+
+    if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
+        av_log(ctx, AV_LOG_INFO, " (inverted)");
 }
 
-static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
+static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 {
     AVFilterContext *ctx = inlink->dst;
     ShowInfoContext *showinfo = ctx->priv;
@@ -50,7 +78,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
     int i, plane, vsub = desc->log2_chroma_h;
 
     for (plane = 0; frame->data[plane] && plane < 4; plane++) {
-        size_t linesize = av_image_get_linesize(frame->format, frame->video->w, plane);
+        size_t linesize = av_image_get_linesize(frame->format, frame->width, plane);
         uint8_t *data = frame->data[plane];
         int h = plane == 1 || plane == 2 ? inlink->h >> vsub : inlink->h;
 
@@ -62,20 +90,47 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
     }
 
     av_log(ctx, AV_LOG_INFO,
-           "n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" "
+           "n:%d pts:%"PRId64" pts_time:%f "
            "fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c "
-           "checksum:%u plane_checksum:[%u %u %u %u]\n",
+           "checksum:%"PRIu32" plane_checksum:[%"PRIu32" %"PRIu32" %"PRIu32" %"PRIu32"]\n",
            showinfo->frame,
-           frame->pts, frame->pts * av_q2d(inlink->time_base), frame->pos,
+           frame->pts, frame->pts * av_q2d(inlink->time_base),
            desc->name,
-           frame->video->pixel_aspect.num, frame->video->pixel_aspect.den,
-           frame->video->w, frame->video->h,
-           !frame->video->interlaced     ? 'P' :         /* Progressive  */
-           frame->video->top_field_first ? 'T' : 'B',    /* Top / Bottom */
-           frame->video->key_frame,
-           av_get_picture_type_char(frame->video->pict_type),
+           frame->sample_aspect_ratio.num, frame->sample_aspect_ratio.den,
+           frame->width, frame->height,
+           !frame->interlaced_frame ? 'P' :         /* Progressive  */
+           frame->top_field_first   ? 'T' : 'B',    /* Top / Bottom */
+           frame->key_frame,
+           av_get_picture_type_char(frame->pict_type),
            checksum, plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3]);
 
+    for (i = 0; i < frame->nb_side_data; i++) {
+        AVFrameSideData *sd = frame->side_data[i];
+
+        av_log(ctx, AV_LOG_INFO, "  side data - ");
+        switch (sd->type) {
+        case AV_FRAME_DATA_PANSCAN:
+            av_log(ctx, AV_LOG_INFO, "pan/scan");
+            break;
+        case AV_FRAME_DATA_A53_CC:
+            av_log(ctx, AV_LOG_INFO, "A/53 closed captions (%d bytes)", sd->size);
+            break;
+        case AV_FRAME_DATA_STEREO3D:
+            dump_stereo3d(ctx, sd);
+            break;
+        case AV_FRAME_DATA_DISPLAYMATRIX:
+            av_log(ctx, AV_LOG_INFO, "displaymatrix: rotation of %.2f degrees",
+                   av_display_rotation_get((int32_t *)sd->data));
+            break;
+        default:
+            av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
+                   sd->type, sd->size);
+            break;
+        }
+
+        av_log(ctx, AV_LOG_INFO, "\n");
+    }
+
     showinfo->frame++;
     return ff_filter_frame(inlink->dst->outputs[0], frame);
 }
@@ -86,7 +141,6 @@ static const AVFilterPad avfilter_vf_showinfo_inputs[] = {
         .type             = AVMEDIA_TYPE_VIDEO,
         .get_video_buffer = ff_null_get_video_buffer,
         .filter_frame     = filter_frame,
-        .min_perms        = AV_PERM_READ,
     },
     { NULL }
 };
@@ -99,12 +153,11 @@ static const AVFilterPad avfilter_vf_showinfo_outputs[] = {
     { NULL }
 };
 
-AVFilter avfilter_vf_showinfo = {
+AVFilter ff_vf_showinfo = {
     .name        = "showinfo",
     .description = NULL_IF_CONFIG_SMALL("Show textual information for each video frame."),
 
     .priv_size = sizeof(ShowInfoContext),
-    .init      = init,
 
     .inputs    = avfilter_vf_showinfo_inputs,