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