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, ...@@ -270,22 +270,28 @@ static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m,
struct vidtv_encoder *e) struct vidtv_encoder *e)
{ {
u32 nbytes = 0; 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; u32 initial_offset = m->mux_buf_offset;
struct vidtv_access_unit *au = e->access_units; struct vidtv_access_unit *au = e->access_units;
u8 *buf = NULL; u8 *buf = NULL;
struct vidtv_mux_pid_ctx *pid_ctx = vidtv_mux_create_pid_ctx_once(m, struct vidtv_mux_pid_ctx *pid_ctx;
be16_to_cpu(e->es_pid));
args.dest_buf = m->mux_buf; /* see SMPTE 302M clause 6.4 */
args.dest_buf_sz = m->mux_buf_sz; if (args.encoder_id == S302M) {
args.pid = be16_to_cpu(e->es_pid); args.send_dts = false;
args.encoder_id = e->id; 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; args.continuity_counter = &pid_ctx->cc;
args.stream_id = be16_to_cpu(e->stream_id);
args.send_pts = true;
while (au) { while (au) {
buf = e->encoder_buf + au->offset; buf = e->encoder_buf + au->offset;
...@@ -295,7 +301,7 @@ static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m, ...@@ -295,7 +301,7 @@ static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m,
args.pts = au->pts; args.pts = au->pts;
args.pcr = m->timing.clk; 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; au = au->next;
} }
......
...@@ -185,6 +185,6 @@ struct pes_write_args { ...@@ -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 * equal to the size of the access unit, since we need space for PES headers, TS headers
* and padding bytes, if any. * 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 #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