Re: [RFC PATCH] [media] coda: Use S_PARM to set nominal framerate for h.264 encoder

2015-01-15 Thread Frédéric Sureau

Hi Philipp,

Le 22/12/2014 17:00, Philipp Zabel a écrit :

The encoder needs to know the nominal framerate for the constant bitrate
control mechanism to work. Currently the only way to set the framerate is
by using VIDIOC_S_PARM on the output queue.

Signed-off-by: Philipp Zabelp.za...@pengutronix.de
---
  drivers/media/platform/coda/coda-common.c | 29 +
  1 file changed, 29 insertions(+)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 39330a7..63eb510 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -803,6 +803,32 @@ static int coda_decoder_cmd(struct file *file, void *fh,
return 0;
  }
  
+static int coda_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)

+{
+   struct coda_ctx *ctx = fh_to_ctx(fh);
+
+   a-parm.output.timeperframe.denominator = 1;
+   a-parm.output.timeperframe.numerator = ctx-params.framerate;
+

Maybe a-parm.output.capability should be set to V4L2_CAP_TIMEPERFRAME here.
I think it is required by GStreamer V4L2 plugin.

+   return 0;
+}
+
+static int coda_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
+{
+   struct coda_ctx *ctx = fh_to_ctx(fh);
+
+   if (a-type == V4L2_BUF_TYPE_VIDEO_OUTPUT 
+   a-parm.output.timeperframe.numerator != 0) {
+   ctx-params.framerate = a-parm.output.timeperframe.denominator
+ / a-parm.output.timeperframe.numerator;
+   }
+
+   a-parm.output.timeperframe.denominator = 1;
+   a-parm.output.timeperframe.numerator = ctx-params.framerate;
+
+   return 0;
+}
+
  static int coda_subscribe_event(struct v4l2_fh *fh,
const struct v4l2_event_subscription *sub)
  {
@@ -843,6 +869,9 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = {
.vidioc_try_decoder_cmd = coda_try_decoder_cmd,
.vidioc_decoder_cmd = coda_decoder_cmd,
  
+	.vidioc_g_parm		= coda_g_parm,

+   .vidioc_s_parm  = coda_s_parm,
+
.vidioc_subscribe_event = coda_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
  };

Thanks for the patch!
Fred
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: coda: Unable to use encoder video_bitrate

2014-12-22 Thread Frédéric Sureau

Hi Philipp,

Le 18/12/2014 17:52, Philipp Zabel a écrit :

Hi Frédéric,

Am Donnerstag, den 18.12.2014, 17:44 +0100 schrieb Frédéric Sureau:

Hi

I am trying to use the coda encoder through Gstreamer on an iMX6-based
board.

I use the (rebased and slightly modified) gstv4l2h264enc plugin from:
https://github.com/hizukiayaka/gst-plugins-good

This pipeline works fine:
gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
video/x-raw,width=1280,height=720 ! videoconvert ! v4l2video0h264enc !
h264parse ! mp4mux ! filesink location=test.mp4

When encoder has no bitrate param set (default=0), video encoding works
well, but bitrate reaches ~2.5Mbps

When I try to set the bitrate with whatever value like 100,000 or
1,000,000, the encoder produces video with bitrate around 480kbps and a
very poor quality.

Here is the gstreamer pipeline I use with bitrate set:
gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
video/x-raw,width=1280,height=720 ! videoconvert ! v4l2video0h264enc
extra-controls=controls,video_bitrate=100; ! h264parse ! mp4mux !
filesink location=test.mp4

The video_bitrate control seems to be correctly passed to the driver by
GStreamer since I can see the VIDIOC_S_CTRL call.

Any idea ?

There is a bug in the register definitions that causes the driver to
apply a wrong mask before writing the bitrate to the register.
I've got a fix for this in the pipeline, sending it right now.

regards
Philipp


Thanks for the patch!
It works fine now after forcing framerate to 30fps (which seems to be 
hardcoded in the driver)


Fred
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


coda: Unable to use encoder video_bitrate

2014-12-18 Thread Frédéric Sureau

Hi

I am trying to use the coda encoder through Gstreamer on an iMX6-based 
board.


I use the (rebased and slightly modified) gstv4l2h264enc plugin from:
https://github.com/hizukiayaka/gst-plugins-good

This pipeline works fine:
gst-launch-1.0 -vvv v4l2src device=/dev/video4 ! 
video/x-raw,width=1280,height=720 ! videoconvert ! v4l2video0h264enc ! 
h264parse ! mp4mux ! filesink location=test.mp4


When encoder has no bitrate param set (default=0), video encoding works 
well, but bitrate reaches ~2.5Mbps


When I try to set the bitrate with whatever value like 100,000 or 
1,000,000, the encoder produces video with bitrate around 480kbps and a 
very poor quality.


Here is the gstreamer pipeline I use with bitrate set:
gst-launch-1.0 -vvv v4l2src device=/dev/video4 ! 
video/x-raw,width=1280,height=720 ! videoconvert ! v4l2video0h264enc 
extra-controls=controls,video_bitrate=100; ! h264parse ! mp4mux ! 
filesink location=test.mp4


The video_bitrate control seems to be correctly passed to the driver by 
GStreamer since I can see the VIDIOC_S_CTRL call.


Any idea ?

Thanks
Fred
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html