Skip to content

Commit cd85b99

Browse files
committed
h264: add H.264 Annex B start codes if required
If the driver reports that it expects H.264 Annex B start codes, provide them. Signed-off-by: Philipp Zabel <[email protected]>
1 parent ae84eeb commit cd85b99

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/h264.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ static void h264_va_slice_to_v4l2(struct request_data *driver_data,
330330
struct v4l2_ctrl_h264_slice_params *slice)
331331
{
332332
slice->size = VASlice->slice_data_size;
333+
if (context->h264_start_code)
334+
slice->size += 3;
333335
slice->header_bit_size = VASlice->slice_data_bit_offset;
334336
slice->first_mb_in_slice = VASlice->first_mb_in_slice;
335337
slice->slice_type = VASlice->slice_type;

src/picture.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "autoconfig.h"
5252

5353
static VAStatus codec_store_buffer(struct request_data *driver_data,
54+
struct object_context *context,
5455
VAProfile profile,
5556
struct object_surface *surface_object,
5657
struct object_buffer *buffer_object)
@@ -63,6 +64,14 @@ static VAStatus codec_store_buffer(struct request_data *driver_data,
6364
* RenderPicture), we can't use a V4L2 buffer directly
6465
* and have to copy from a regular buffer.
6566
*/
67+
if (context->h264_start_code) {
68+
static const char start_code[3] = { 0x00, 0x00, 0x01 };
69+
70+
memcpy(surface_object->source_data +
71+
surface_object->slices_size,
72+
start_code, sizeof(start_code));
73+
surface_object->slices_size += sizeof(start_code);
74+
}
6675
memcpy(surface_object->source_data +
6776
surface_object->slices_size,
6877
buffer_object->data,
@@ -255,7 +264,8 @@ VAStatus RequestRenderPicture(VADriverContextP context, VAContextID context_id,
255264
if (buffer_object == NULL)
256265
return VA_STATUS_ERROR_INVALID_BUFFER;
257266

258-
rc = codec_store_buffer(driver_data, config_object->profile,
267+
rc = codec_store_buffer(driver_data, context_object,
268+
config_object->profile,
259269
surface_object, buffer_object);
260270
if (rc != VA_STATUS_SUCCESS)
261271
return rc;

0 commit comments

Comments
 (0)