diff --git a/libv4l-rockchip/Makefile b/libv4l-rockchip/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d658692717d835b32eb63459a74fda4543246bab --- /dev/null +++ b/libv4l-rockchip/Makefile @@ -0,0 +1,71 @@ +# Copyright 2014 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +#if WITH_V4L_PLUGINS +#libv4l2plugin_LTLIBRARIES = libv4l-encplugin.la +#endif +# +#libv4l_encplugin_la_SOURCES = \ +# libv4l-encplugin-rockchip.c \ +# libvpu/rk_vepu.c \ +# libvpu/rk_vepu_debug.c \ +# libvpu/vp8_enc/encasiccontroller.c \ +# libvpu/vp8_enc/encasiccontroller_v2.c \ +# libvpu/vp8_enc/rk_vp8encapi.c \ +# libvpu/vp8_enc/vp8codeframe.c \ +# libvpu/vp8_enc/vp8encapi.c \ +# libvpu/vp8_enc/vp8entropy.c \ +# libvpu/vp8_enc/vp8header.c \ +# libvpu/vp8_enc/vp8init.c \ +# libvpu/vp8_enc/vp8macroblocktools.c \ +# libvpu/vp8_enc/vp8picparameterset.c \ +# libvpu/vp8_enc/vp8picturebuffer.c \ +# libvpu/vp8_enc/vp8putbits.c \ +# libvpu/vp8_enc/vp8ratecontrol.c \ +# libvpu/vp8_enc/vpu_mem.c +#libv4l_encplugin_la_CPPFLAGS = $(CFLAG_VISIBILITY) +#libv4l_encplugin_la_LDFLAGS = -avoid-version -module -shared -export-dynamic +#libv4l_encplugin_la_LIBADD = -lpthread + +CC=gcc +CFLAGS = -fPIC -Wall -Wextra -O2 -g -I. +LDFLAGS = -shared -export-dynamic +RM = rm -f +TARGET_LIB = libv4l-encplugin.so + +SRCS = \ + libv4l-encplugin-rockchip.c \ + libvpu/rk_vepu.c \ + libvpu/rk_vepu_debug.c \ + libvpu/vp8_enc/encasiccontroller.c \ + libvpu/vp8_enc/encasiccontroller_v2.c \ + libvpu/vp8_enc/rk_vp8encapi.c \ + libvpu/vp8_enc/vp8codeframe.c \ + libvpu/vp8_enc/vp8encapi.c \ + libvpu/vp8_enc/vp8entropy.c \ + libvpu/vp8_enc/vp8header.c \ + libvpu/vp8_enc/vp8init.c \ + libvpu/vp8_enc/vp8macroblocktools.c \ + libvpu/vp8_enc/vp8picparameterset.c \ + libvpu/vp8_enc/vp8picturebuffer.c \ + libvpu/vp8_enc/vp8putbits.c \ + libvpu/vp8_enc/vp8ratecontrol.c \ + libvpu/vp8_enc/vpu_mem.c + +OBJS = $(SRCS:.c=.o) + +.PHONY: all +all: ${TARGET_LIB} + +$(TARGET_LIB): $(OBJS) + $(CC) ${LDFLAGS} -o $@ $^ + +$(SRCS:.c=.d):%.d:%.c + $(CC) $(CFLAGS) -MM $< >$@ + +include $(SRCS:.c=.d) + +.PHONY: clean +clean: + -${RM} ${TARGET_LIB} ${OBJS} $(SRCS:.c=.d) diff --git a/libv4l-rockchip/Makefile.am b/libv4l-rockchip/Makefile.am deleted file mode 100644 index bfcc1011943dbee5639481e407c355285f7d1d51..0000000000000000000000000000000000000000 --- a/libv4l-rockchip/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2014 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -if WITH_V4L_PLUGINS -libv4l2plugin_LTLIBRARIES = libv4l-encplugin.la -endif - -libv4l_encplugin_la_SOURCES = \ - libv4l-encplugin-rockchip.c \ - libvpu/rk_vepu.c \ - libvpu/rk_vepu_debug.c \ - libvpu/vp8_enc/encasiccontroller.c \ - libvpu/vp8_enc/encasiccontroller_v2.c \ - libvpu/vp8_enc/rk_vp8encapi.c \ - libvpu/vp8_enc/vp8codeframe.c \ - libvpu/vp8_enc/vp8encapi.c \ - libvpu/vp8_enc/vp8entropy.c \ - libvpu/vp8_enc/vp8header.c \ - libvpu/vp8_enc/vp8init.c \ - libvpu/vp8_enc/vp8macroblocktools.c \ - libvpu/vp8_enc/vp8picparameterset.c \ - libvpu/vp8_enc/vp8picturebuffer.c \ - libvpu/vp8_enc/vp8putbits.c \ - libvpu/vp8_enc/vp8ratecontrol.c \ - libvpu/vp8_enc/vpu_mem.c -libv4l_encplugin_la_CPPFLAGS = $(CFLAG_VISIBILITY) -libv4l_encplugin_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -libv4l_encplugin_la_LIBADD = -lpthread diff --git a/libv4l-rockchip/libv4l-encplugin-rockchip.c b/libv4l-rockchip/libv4l-encplugin-rockchip.c index 7edda586cada847a99f04d0ad57196b9de372fdd..b648d316a4369ddbd99dc1f09d57cf0a2c43c95d 100644 --- a/libv4l-rockchip/libv4l-encplugin-rockchip.c +++ b/libv4l-rockchip/libv4l-encplugin-rockchip.c @@ -14,7 +14,6 @@ #include <string.h> #include <sys/queue.h> #include <sys/syscall.h> -#include "config.h" /* For HAVE_VISIBILITY */ #include "libv4l-plugin.h" #include "libvpu/rk_vepu_debug.h" #include "libvpu/rk_vepu_interface.h" @@ -195,7 +194,7 @@ static void *plugin_init(int fd) queue_init(&ctx->pending_buffers); memset(&ext_ctrl, 0, sizeof(ext_ctrl)); - ext_ctrl.id = V4L2_CID_PRIVATE_RK3288_GET_PARAMS; + ext_ctrl.id = V4L2_CID_PRIVATE_HANTRO_RET_PARAMS; ret = SYS_IOCTL(fd, VIDIOC_QUERY_EXT_CTRL, &ext_ctrl); if (ret) { goto fail; @@ -386,7 +385,7 @@ static int ioctl_dqbuf_locked(struct encoder_context *ctx, int fd, if (bytesused) { memset(ctx->get_param_payload, 0, ctx->get_param_payload_size); memset(&v4l2_ctrl, 0, sizeof(v4l2_ctrl)); - v4l2_ctrl.id = V4L2_CID_PRIVATE_RK3288_GET_PARAMS; + v4l2_ctrl.id = V4L2_CID_PRIVATE_HANTRO_RET_PARAMS; v4l2_ctrl.size = ctx->get_param_payload_size; v4l2_ctrl.ptr = ctx->get_param_payload; memset(&ext_ctrls, 0, sizeof(ext_ctrls)); @@ -604,6 +603,8 @@ static int initialize_libvpu(struct encoder_context *ctx, int fd) if (ret) return ret; init_param.input_format = format.fmt.pix_mp.pixelformat; + init_param.width = format.fmt.pix_mp.width; + init_param.height = format.fmt.pix_mp.height; /* Get the output format. */ memset(&format, 0, sizeof(format)); @@ -614,14 +615,16 @@ static int initialize_libvpu(struct encoder_context *ctx, int fd) init_param.output_format = format.fmt.pix_mp.pixelformat; /* Get the cropped size. */ - struct v4l2_crop crop; - memset(&crop, 0, sizeof(crop)); - crop.type = ctx->output_streamon_type; - ret = SYS_IOCTL(fd, VIDIOC_G_CROP, &crop); - if (ret) - return ret; - init_param.width = crop.c.width; - init_param.height = crop.c.height; +// struct v4l2_crop crop; +// memset(&crop, 0, sizeof(crop)); +// crop.type = ctx->output_streamon_type; +// ret = SYS_IOCTL(fd, VIDIOC_G_CROP, &crop); +// if (ret) +// return ret; +// init_param.width = crop.c.width; +// init_param.height = crop.c.height; + + printf("%d %d\n", init_param.width, init_param.height); /* * If the encoder library has initialized and parameters have not @@ -751,10 +754,14 @@ static const char* v4l_cmd2str(unsigned long int cmd) return "VIDIOC_G_EXT_CTRLS"; case VIDIOC_S_EXT_CTRLS: return "VIDIOC_S_EXT_CTRLS"; + case VIDIOC_QUERY_EXT_CTRL: + return "VIDIOC_QUERY_EXT_CTRL"; case VIDIOC_QUERYBUF: return "VIDIOC_QUERYBUF"; case VIDIOC_ENCODER_CMD: return "VIDIOC_ENCODER_CMD"; + case VIDIOC_CROPCAP: + return "VIDIOC_CROPCAP"; default: return "UNKNOWN"; } diff --git a/libv4l-rockchip/libvpu/rk_vepu.c b/libv4l-rockchip/libvpu/rk_vepu.c index f3d34f78ebcb67b6eb1b5fdfa4f8e91bf4248d7b..82403976c2ab7d351c060285c081ae823ea76afa 100644 --- a/libv4l-rockchip/libvpu/rk_vepu.c +++ b/libv4l-rockchip/libvpu/rk_vepu.c @@ -24,9 +24,9 @@ void *rk_vepu_init(struct rk_vepu_init_param *param) { return NULL; } - enc->rk_ctrl_ids[0] = V4L2_CID_PRIVATE_RK3288_HEADER; - enc->rk_ctrl_ids[1] = V4L2_CID_PRIVATE_RK3288_REG_PARAMS; - enc->rk_ctrl_ids[2] = V4L2_CID_PRIVATE_RK3288_HW_PARAMS; + enc->rk_ctrl_ids[0] = V4L2_CID_PRIVATE_HANTRO_HEADER; + enc->rk_ctrl_ids[1] = V4L2_CID_PRIVATE_HANTRO_REG_PARAMS; + enc->rk_ctrl_ids[2] = V4L2_CID_PRIVATE_HANTRO_HW_PARAMS; retval = enc->ops->init(enc, param); if (retval < 0) { diff --git a/libv4l-rockchip/libvpu/rk_vepu_interface.h b/libv4l-rockchip/libvpu/rk_vepu_interface.h index b9d93ee843018edcb2600d07a8a3a759580373a6..fd1dd8595d9fbebbee0f803423944bd2a8665bfc 100644 --- a/libv4l-rockchip/libvpu/rk_vepu_interface.h +++ b/libv4l-rockchip/libvpu/rk_vepu_interface.h @@ -17,12 +17,12 @@ #include <stddef.h> #include <stdint.h> -/* TODO(wuchengli): Remove these after the header is updated. */ -#define V4L2_CID_CUSTOM_BASE (V4L2_CID_USER_BASE | 0x1000) -#define V4L2_CID_PRIVATE_RK3288_HEADER (V4L2_CID_CUSTOM_BASE) -#define V4L2_CID_PRIVATE_RK3288_REG_PARAMS (V4L2_CID_CUSTOM_BASE + 1) -#define V4L2_CID_PRIVATE_RK3288_HW_PARAMS (V4L2_CID_CUSTOM_BASE + 2) -#define V4L2_CID_PRIVATE_RK3288_GET_PARAMS (V4L2_CID_CUSTOM_BASE + 3) +#define V4L2_CID_USER_HANTRO_ENCODER_BASE (V4L2_CID_USER_BASE + 0x2000) +#define V4L2_CID_PRIVATE_HANTRO_HEADER (V4L2_CID_USER_HANTRO_ENCODER_BASE + 0) +#define V4L2_CID_PRIVATE_HANTRO_REG_PARAMS (V4L2_CID_USER_HANTRO_ENCODER_BASE + 1) +#define V4L2_CID_PRIVATE_HANTRO_HW_PARAMS (V4L2_CID_USER_HANTRO_ENCODER_BASE + 2) +#define V4L2_CID_PRIVATE_HANTRO_RET_PARAMS (V4L2_CID_USER_HANTRO_ENCODER_BASE + 3) + /* The maximum number of controls returned by rk_vepu_get_config(). */ #define MAX_NUM_GET_CONFIG_CTRLS 5 diff --git a/libv4l-rockchip_v2/Makefile b/libv4l-rockchip_v2/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..362b273c6a6b72daaea806a0df787e494872f800 --- /dev/null +++ b/libv4l-rockchip_v2/Makefile @@ -0,0 +1,58 @@ +# Copyright 2016 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +#if WITH_V4L_PLUGINS +#libv4l2plugin_LTLIBRARIES = libv4l-encplugin.la +#endif +# +#libv4l_encplugin_la_SOURCES = \ +# libv4l-encplugin-rockchip.c \ +# libvepu/streams.c \ +# libvepu/rk_vepu.c \ +# libvepu/rk_vepu_debug.c \ +# libvepu/common/rk_venc_rate_control.c \ +# libvepu/h264e/h264e.c \ +# libvepu/h264e/h264e_rate_control.c \ +# libvepu/vp8e/vp8e.c \ +# libvepu/vp8e/boolhuff.c \ +# libvepu/vp8e/vp8e_bitstream.c \ +# libvepu/vp8e/vp8e_prob_adapt.c +# +#libv4l_encplugin_la_CPPFLAGS = $(CFLAG_VISIBILITY) +#libv4l_encplugin_la_LDFLAGS = -avoid-version -module -shared -export-dynamic +#libv4l_encplugin_la_LIBADD = -lpthread +# +CFLAGS = -fPIC -Wall -Wextra -O2 -g -I. +LDFLAGS = -shared -export-dynamic +RM = rm -f +TARGET_LIB = libv4l-encplugin.so + +SRCS = \ + libv4l-encplugin-rockchip.c \ + libvepu/streams.c \ + libvepu/rk_vepu.c \ + libvepu/rk_vepu_debug.c \ + libvepu/common/rk_venc_rate_control.c \ + libvepu/h264e/h264e.c \ + libvepu/h264e/h264e_rate_control.c \ + libvepu/vp8e/vp8e.c \ + libvepu/vp8e/boolhuff.c \ + libvepu/vp8e/vp8e_bitstream.c \ + libvepu/vp8e/vp8e_prob_adapt.c +OBJS = $(SRCS:.c=.o) + +.PHONY: all +all: ${TARGET_LIB} + +$(TARGET_LIB): $(OBJS) + $(CC) ${LDFLAGS} -o $@ $^ + +$(SRCS:.c=.d):%.d:%.c + $(CC) $(CFLAGS) -MM $< >$@ + +include $(SRCS:.c=.d) + +.PHONY: clean +clean: + -${RM} ${TARGET_LIB} ${OBJS} $(SRCS:.c=.d) diff --git a/libv4l-rockchip_v2/Makefile.am b/libv4l-rockchip_v2/Makefile.am deleted file mode 100644 index 1ae7d107f76f5a58cc521ea80734aed95a82f13e..0000000000000000000000000000000000000000 --- a/libv4l-rockchip_v2/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2016 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -if WITH_V4L_PLUGINS -libv4l2plugin_LTLIBRARIES = libv4l-encplugin.la -endif - -libv4l_encplugin_la_SOURCES = \ - libv4l-encplugin-rockchip.c \ - libvepu/streams.c \ - libvepu/rk_vepu.c \ - libvepu/rk_vepu_debug.c \ - libvepu/common/rk_venc_rate_control.c \ - libvepu/h264e/h264e.c \ - libvepu/h264e/h264e_rate_control.c \ - libvepu/vp8e/vp8e.c \ - libvepu/vp8e/boolhuff.c \ - libvepu/vp8e/vp8e_bitstream.c \ - libvepu/vp8e/vp8e_prob_adapt.c - -libv4l_encplugin_la_CPPFLAGS = $(CFLAG_VISIBILITY) -libv4l_encplugin_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -libv4l_encplugin_la_LIBADD = -lpthread diff --git a/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c b/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c index 009c207000a1ae2987724fbf5d1ff6d1a599a965..9044ef6aa999d5d901bb1de679520f0a05a264e5 100644 --- a/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c +++ b/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c @@ -14,7 +14,6 @@ #include <string.h> #include <sys/queue.h> #include <sys/syscall.h> -#include "config.h" /* For HAVE_VISIBILITY */ #include "libv4l-plugin.h" #include "libvepu/rk_vepu_debug.h" #include "libvepu/rk_vepu_interface.h"