root/media/cast/test/utility/generate_barcode_video.cc

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. DumpPlane
  2. main

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <cstdio>
#include <cstdlib>

#include "media/base/video_frame.h"
#include "media/cast/test/utility/barcode.h"

void DumpPlane(scoped_refptr<media::VideoFrame> frame,
               int plane) {
  for (int row = 0; row < frame->rows(plane); row++) {
    CHECK_EQ(frame->row_bytes(plane),
             fwrite(frame->data(plane) + frame->stride(plane) * row,
                    1,
                    frame->row_bytes(plane),
                    stdout));
  }
}

int main(int argc, char **argv) {
  if (argc < 5) {
    fprintf(stderr, "Usage: generate_barcode_video "
            "<width> <height> <fps> <frames> >output.y4m\n");
    exit(1);
  }
  int width = atoi(argv[1]);
  int height = atoi(argv[2]);
  int fps = atoi(argv[3]);
  uint16 wanted_frames = atoi(argv[4]);
  scoped_refptr<media::VideoFrame> frame =
      media::VideoFrame::CreateBlackFrame(gfx::Size(width, height));
  printf("YUV4MPEG2 W%d H%d F%d:1 Ip C420mpeg2\n", width, height, fps);
  for (uint16 frame_id = 1; frame_id <= wanted_frames; frame_id++) {
    CHECK(media::cast::test::EncodeBarcode(frame_id, frame));
    printf("FRAME\n");
    DumpPlane(frame, media::VideoFrame::kYPlane);
    DumpPlane(frame, media::VideoFrame::kUPlane);
    DumpPlane(frame, media::VideoFrame::kVPlane);
  }
}

/* [<][>][^][v][top][bottom][index][help] */