From 8b8182da6e16dfd0820ef2418c1bb66d4bcc8079 Mon Sep 17 00:00:00 2001 From: Andrzej Hajda Date: Mon, 2 Jul 2012 10:50:47 +0200 Subject: v4l-mfc-encoder: version 0.1 Signed-off-by: Andrzej Hajda Signed-off-by: Kamil Debski --- v4l2-mfc-encoder/main.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 v4l2-mfc-encoder/main.c (limited to 'v4l2-mfc-encoder/main.c') diff --git a/v4l2-mfc-encoder/main.c b/v4l2-mfc-encoder/main.c new file mode 100644 index 0000000..5681bab --- /dev/null +++ b/v4l2-mfc-encoder/main.c @@ -0,0 +1,106 @@ +/* + * mfc codec encoding example application + * Andrzej Hajda + * + * Main file of the application. + * + * Copyright 2012 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include "common.h" +#include "args.h" +#include "in_demo.h" +#include "in_camera.h" +#include "out_file.h" +#include "io_dev.h" +#include "mfc.h" +#include "v4l_dev.h" + +int main(int argc, char *argv[]) +{ + struct options opts; + + struct io_dev *input; + struct io_dev *mfc; + struct io_dev *output; + int i; + + struct io_dev *chain[3] = {}; + + printf("mfc codec encoding example application\n" + "Andrzej Hajda \n" + "Copyright 2012 Samsung Electronics Co., Ltd.\n\n"); + + if (parse_args(&opts, argc, argv)) { + print_usage(argv[0]); + return 1; + } + + if (opts.in_name) + input = in_camera_create(opts.in_name); + else + input = in_demo_create(opts.width, opts.height); + if (input == NULL) + return 1; + chain[0] = input; + + input->io[DIR_OUT].limit = opts.duration; + + mfc = mfc_create(opts.mfc_name); + if (mfc == NULL) + return 1; + chain[1] = mfc; + + if (mfc_set_fmt(mfc, DIR_IN, opts.width, opts.height)) + return 1; + + if (mfc_set_codec(mfc, DIR_OUT, opts.codec)) + return 1; + + if (mfc_set_rate(mfc, opts.rate)) + return 1; + + if (mfc_set_bitrate(mfc, opts.bitrate)) + return 1; + + mfc_set_mpeg_control(mfc, V4L2_CID_MPEG_VIDEO_B_FRAMES, 2); + + if (opts.in_name) + if (v4l_copy_fmt(mfc, DIR_IN, input, DIR_OUT)) + return 1; + + output = out_file_create(opts.out_name); + if (output == NULL) + return 1; + chain[2] = output; + + if (dev_bufs_create(input, mfc, MFC_ENC_IN_NBUF)) + return 1; + + if (dev_bufs_create(mfc, output, MFC_ENC_OUT_NBUF)) + return 1; + + if (process_chain(chain, array_len(chain))) + return 1; + + for (i = 0; i < array_len(chain); ++i) + chain[i]->ops->destroy(chain[i]); + + return 0; +} -- cgit v1.2.3