Commit 163d72a2 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: vidtv: avoid copying data for PES structs

Minimize the number of data copies and initialization at
the code, passing them as pointers instead of duplicating
the data.

The only case where we're keeping the data copy is at
vidtv_pes_write_h(), as it needs a copy of the passed
arguments. On such case, we're being more explicit.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 0a33ab16
......@@ -270,22 +270,28 @@ static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m,
struct vidtv_encoder *e)
{
u32 nbytes = 0;
struct pes_write_args args = {};
struct pes_write_args args = {
.dest_buf = m->mux_buf,
.dest_buf_sz = m->mux_buf_sz,
.pid = be16_to_cpu(e->es_pid),
.encoder_id = e->id,
.stream_id = be16_to_cpu(e->stream_id),
.send_pts = true, /* forbidden value '01'... */
.send_dts = false, /* ...for PTS_DTS flags */
};
u32 initial_offset = m->mux_buf_offset;
struct vidtv_access_unit *au = e->access_units;
u8 *buf = NULL;
struct vidtv_mux_pid_ctx *pid_ctx = vidtv_mux_create_pid_ctx_once(m,
be16_to_cpu(e->es_pid));
struct vidtv_mux_pid_ctx *pid_ctx;
args.dest_buf = m->mux_buf;
args.dest_buf_sz = m->mux_buf_sz;
args.pid = be16_to_cpu(e->es_pid);
args.encoder_id = e->id;
args.continuity_counter = &pid_ctx->cc;
args.stream_id = be16_to_cpu(e->stream_id);
/* see SMPTE 302M clause 6.4 */
if (args.encoder_id == S302M) {
args.send_dts = false;
args.send_pts = true;
}
pid_ctx = vidtv_mux_create_pid_ctx_once(m, be16_to_cpu(e->es_pid));
args.continuity_counter = &pid_ctx->cc;
while (au) {
buf = e->encoder_buf + au->offset;
......@@ -295,7 +301,7 @@ static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m,
args.pts = au->pts;
args.pcr = m->timing.clk;
m->mux_buf_offset += vidtv_pes_write_into(args);
m->mux_buf_offset += vidtv_pes_write_into(&args);
au = au->next;
}
......
......@@ -185,6 +185,6 @@ struct pes_write_args {
* equal to the size of the access unit, since we need space for PES headers, TS headers
* and padding bytes, if any.
*/
u32 vidtv_pes_write_into(struct pes_write_args args);
u32 vidtv_pes_write_into(struct pes_write_args *args);
#endif // VIDTV_PES_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment