Lines Matching refs:e

165 static void vidtv_s302m_access_unit_destroy(struct vidtv_encoder *e)  in vidtv_s302m_access_unit_destroy()  argument
167 struct vidtv_access_unit *head = e->access_units; in vidtv_s302m_access_unit_destroy()
176 e->access_units = NULL; in vidtv_s302m_access_unit_destroy()
179 static void vidtv_s302m_alloc_au(struct vidtv_encoder *e) in vidtv_s302m_alloc_au() argument
184 if (e->sync && e->sync->is_video_encoder) { in vidtv_s302m_alloc_au()
185 sync_au = e->sync->access_units; in vidtv_s302m_alloc_au()
188 temp = vidtv_s302m_access_unit_init(e->access_units); in vidtv_s302m_alloc_au()
189 if (!e->access_units) in vidtv_s302m_alloc_au()
190 e->access_units = temp; in vidtv_s302m_alloc_au()
198 e->access_units = vidtv_s302m_access_unit_init(NULL); in vidtv_s302m_alloc_au()
202 vidtv_s302m_compute_sample_count_from_video(struct vidtv_encoder *e) in vidtv_s302m_compute_sample_count_from_video() argument
204 struct vidtv_access_unit *sync_au = e->sync->access_units; in vidtv_s302m_compute_sample_count_from_video()
205 struct vidtv_access_unit *au = e->access_units; in vidtv_s302m_compute_sample_count_from_video()
210 vau_duration_usecs = USEC_PER_SEC / e->sync->sampling_rate_hz; in vidtv_s302m_compute_sample_count_from_video()
211 sample_duration_usecs = USEC_PER_SEC / e->sampling_rate_hz; in vidtv_s302m_compute_sample_count_from_video()
221 static void vidtv_s302m_compute_pts_from_video(struct vidtv_encoder *e) in vidtv_s302m_compute_pts_from_video() argument
223 struct vidtv_access_unit *au = e->access_units; in vidtv_s302m_compute_pts_from_video()
224 struct vidtv_access_unit *sync_au = e->sync->access_units; in vidtv_s302m_compute_pts_from_video()
234 static u16 vidtv_s302m_get_sample(struct vidtv_encoder *e) in vidtv_s302m_get_sample() argument
238 struct vidtv_s302m_ctx *ctx = e->ctx; in vidtv_s302m_get_sample()
240 if (!e->src_buf) { in vidtv_s302m_get_sample()
246 if (e->src_buf_offset >= ARRAY_SIZE(beethoven_fur_elise)) in vidtv_s302m_get_sample()
247 e->src_buf_offset = 0; in vidtv_s302m_get_sample()
249 ctx->last_tone = beethoven_fur_elise[e->src_buf_offset].note; in vidtv_s302m_get_sample()
250 ctx->last_duration = beethoven_fur_elise[e->src_buf_offset].duration * in vidtv_s302m_get_sample()
252 e->src_buf_offset++; in vidtv_s302m_get_sample()
269 if (e->src_buf_offset > e->src_buf_sz) { in vidtv_s302m_get_sample()
271 e->src_buf_offset, in vidtv_s302m_get_sample()
272 e->src_buf_sz); in vidtv_s302m_get_sample()
274 e->src_buf_offset = 0; in vidtv_s302m_get_sample()
277 if (e->src_buf_offset >= e->src_buf_sz) { in vidtv_s302m_get_sample()
279 if (e->last_sample_cb) in vidtv_s302m_get_sample()
280 e->last_sample_cb(e->sample_count); in vidtv_s302m_get_sample()
282 e->src_buf_offset = 0; in vidtv_s302m_get_sample()
285 sample = *(u16 *)(e->src_buf + e->src_buf_offset); in vidtv_s302m_get_sample()
290 static u32 vidtv_s302m_write_frame(struct vidtv_encoder *e, in vidtv_s302m_write_frame() argument
293 struct vidtv_s302m_ctx *ctx = e->ctx; in vidtv_s302m_write_frame()
313 nbytes += vidtv_memcpy(e->encoder_buf, in vidtv_s302m_write_frame()
314 e->encoder_buf_offset, in vidtv_s302m_write_frame()
319 e->encoder_buf_offset += nbytes; in vidtv_s302m_write_frame()
328 static u32 vidtv_s302m_write_h(struct vidtv_encoder *e, u32 p_sz) in vidtv_s302m_write_h() argument
336 nbytes += vidtv_memcpy(e->encoder_buf, in vidtv_s302m_write_h()
337 e->encoder_buf_offset, in vidtv_s302m_write_h()
338 e->encoder_buf_sz, in vidtv_s302m_write_h()
342 e->encoder_buf_offset += nbytes; in vidtv_s302m_write_h()
346 static void vidtv_s302m_write_frames(struct vidtv_encoder *e) in vidtv_s302m_write_frames() argument
348 struct vidtv_access_unit *au = e->access_units; in vidtv_s302m_write_frames()
349 struct vidtv_s302m_ctx *ctx = e->ctx; in vidtv_s302m_write_frames()
360 nbytes_per_unit = vidtv_s302m_write_h(e, au_sz); in vidtv_s302m_write_frames()
363 sample = vidtv_s302m_get_sample(e); in vidtv_s302m_write_frames()
364 nbytes_per_unit += vidtv_s302m_write_frame(e, sample); in vidtv_s302m_write_frames()
366 if (e->src_buf) in vidtv_s302m_write_frames()
367 e->src_buf_offset += sizeof(u16); in vidtv_s302m_write_frames()
369 e->sample_count++; in vidtv_s302m_write_frames()
390 static void *vidtv_s302m_encode(struct vidtv_encoder *e) in vidtv_s302m_encode() argument
392 struct vidtv_s302m_ctx *ctx = e->ctx; in vidtv_s302m_encode()
407 vidtv_s302m_access_unit_destroy(e); in vidtv_s302m_encode()
408 vidtv_s302m_alloc_au(e); in vidtv_s302m_encode()
410 if (e->sync && e->sync->is_video_encoder) { in vidtv_s302m_encode()
411 vidtv_s302m_compute_sample_count_from_video(e); in vidtv_s302m_encode()
412 vidtv_s302m_compute_pts_from_video(e); in vidtv_s302m_encode()
414 e->access_units->num_samples = FF_S302M_DEFAULT_NUM_FRAMES; in vidtv_s302m_encode()
415 e->access_units->pts = (ctx->au_count * FF_S302M_DEFAULT_PTS_INCREMENT) + in vidtv_s302m_encode()
419 vidtv_s302m_write_frames(e); in vidtv_s302m_encode()
421 return e->encoder_buf; in vidtv_s302m_encode()
424 static u32 vidtv_s302m_clear(struct vidtv_encoder *e) in vidtv_s302m_clear() argument
426 struct vidtv_access_unit *au = e->access_units; in vidtv_s302m_clear()
434 vidtv_s302m_access_unit_destroy(e); in vidtv_s302m_clear()
435 memset(e->encoder_buf, 0, VIDTV_S302M_BUF_SZ); in vidtv_s302m_clear()
436 e->encoder_buf_offset = 0; in vidtv_s302m_clear()
446 struct vidtv_encoder *e; in vidtv_s302m_encoder_init() local
448 e = kzalloc(sizeof(*e), GFP_KERNEL); in vidtv_s302m_encoder_init()
449 if (!e) in vidtv_s302m_encoder_init()
452 e->id = S302M; in vidtv_s302m_encoder_init()
455 e->name = kstrdup(args.name, GFP_KERNEL); in vidtv_s302m_encoder_init()
457 e->encoder_buf = vzalloc(VIDTV_S302M_BUF_SZ); in vidtv_s302m_encoder_init()
458 if (!e->encoder_buf) in vidtv_s302m_encoder_init()
461 e->encoder_buf_sz = VIDTV_S302M_BUF_SZ; in vidtv_s302m_encoder_init()
462 e->encoder_buf_offset = 0; in vidtv_s302m_encoder_init()
464 e->sample_count = 0; in vidtv_s302m_encoder_init()
466 e->src_buf = (args.src_buf) ? args.src_buf : NULL; in vidtv_s302m_encoder_init()
467 e->src_buf_sz = (args.src_buf) ? args.src_buf_sz : 0; in vidtv_s302m_encoder_init()
468 e->src_buf_offset = 0; in vidtv_s302m_encoder_init()
470 e->is_video_encoder = false; in vidtv_s302m_encoder_init()
476 e->ctx = ctx; in vidtv_s302m_encoder_init()
479 e->encode = vidtv_s302m_encode; in vidtv_s302m_encoder_init()
480 e->clear = vidtv_s302m_clear; in vidtv_s302m_encoder_init()
482 e->es_pid = cpu_to_be16(args.es_pid); in vidtv_s302m_encoder_init()
483 e->stream_id = cpu_to_be16(PES_PRIVATE_STREAM_1); in vidtv_s302m_encoder_init()
485 e->sync = args.sync; in vidtv_s302m_encoder_init()
486 e->sampling_rate_hz = S302M_SAMPLING_RATE_HZ; in vidtv_s302m_encoder_init()
488 e->last_sample_cb = args.last_sample_cb; in vidtv_s302m_encoder_init()
490 e->destroy = vidtv_s302m_encoder_destroy; in vidtv_s302m_encoder_init()
496 args.head->next = e; in vidtv_s302m_encoder_init()
499 e->next = NULL; in vidtv_s302m_encoder_init()
501 return e; in vidtv_s302m_encoder_init()
504 vfree(e->encoder_buf); in vidtv_s302m_encoder_init()
507 kfree(e->name); in vidtv_s302m_encoder_init()
508 kfree(e); in vidtv_s302m_encoder_init()
512 void vidtv_s302m_encoder_destroy(struct vidtv_encoder *e) in vidtv_s302m_encoder_destroy() argument
514 if (e->id != S302M) { in vidtv_s302m_encoder_destroy()
519 vidtv_s302m_access_unit_destroy(e); in vidtv_s302m_encoder_destroy()
520 kfree(e->name); in vidtv_s302m_encoder_destroy()
521 vfree(e->encoder_buf); in vidtv_s302m_encoder_destroy()
522 kfree(e->ctx); in vidtv_s302m_encoder_destroy()
523 kfree(e); in vidtv_s302m_encoder_destroy()