Remove INJECT_EVENTS permissions from test APKs.
[chromium-blink-merge.git] / media / cast / test / utility / generate_barcode_video.cc
blobe917ecdf111ee559fef3ef3df9a3052ecd13a77e
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <cstdio>
6 #include <cstdlib>
8 #include "base/logging.h"
9 #include "media/base/video_frame.h"
10 #include "media/cast/test/utility/barcode.h"
12 void DumpPlane(scoped_refptr<media::VideoFrame> frame,
13 int plane) {
14 for (int row = 0; row < frame->rows(plane); row++) {
15 CHECK_EQ(static_cast<size_t>(frame->row_bytes(plane)),
16 fwrite(frame->data(plane) + frame->stride(plane) * row,
18 frame->row_bytes(plane),
19 stdout));
23 int main(int argc, char **argv) {
24 if (argc < 5) {
25 fprintf(stderr, "Usage: generate_barcode_video "
26 "<width> <height> <fps> <frames> >output.y4m\n");
27 exit(1);
29 int width = atoi(argv[1]);
30 int height = atoi(argv[2]);
31 int fps = atoi(argv[3]);
32 uint16 wanted_frames = atoi(argv[4]);
33 scoped_refptr<media::VideoFrame> frame =
34 media::VideoFrame::CreateBlackFrame(gfx::Size(width, height));
35 printf("YUV4MPEG2 W%d H%d F%d:1 Ip C420mpeg2\n", width, height, fps);
36 for (uint16 frame_id = 1; frame_id <= wanted_frames; frame_id++) {
37 CHECK(media::cast::test::EncodeBarcode(frame_id, frame));
38 printf("FRAME\n");
39 DumpPlane(frame, media::VideoFrame::kYPlane);
40 DumpPlane(frame, media::VideoFrame::kUPlane);
41 DumpPlane(frame, media::VideoFrame::kVPlane);