• Home
  • Raw
  • Download

Lines Matching full:s

37 void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)  in ff_mpv_decode_init()  argument
39 ff_mpv_common_defaults(s); in ff_mpv_decode_init()
41 s->avctx = avctx; in ff_mpv_decode_init()
42 s->width = avctx->coded_width; in ff_mpv_decode_init()
43 s->height = avctx->coded_height; in ff_mpv_decode_init()
44 s->codec_id = avctx->codec->id; in ff_mpv_decode_init()
45 s->workaround_bugs = avctx->workaround_bugs; in ff_mpv_decode_init()
48 s->codec_tag = ff_toupper4(avctx->codec_tag); in ff_mpv_decode_init()
55 MpegEncContext *const s = dst->priv_data; in ff_mpeg_update_thread_context() local
61 av_assert0(s != s1); in ff_mpeg_update_thread_context()
65 if (!s->context_initialized) { in ff_mpeg_update_thread_context()
66 void *private_ctx = s->private_ctx; in ff_mpeg_update_thread_context()
68 memcpy(s, s1, sizeof(*s)); in ff_mpeg_update_thread_context()
70 s->avctx = dst; in ff_mpeg_update_thread_context()
71 s->private_ctx = private_ctx; in ff_mpeg_update_thread_context()
72 s->bitstream_buffer = NULL; in ff_mpeg_update_thread_context()
73 s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0; in ff_mpeg_update_thread_context()
76 // s->picture_range_start += MAX_PICTURE_COUNT; in ff_mpeg_update_thread_context()
77 // s->picture_range_end += MAX_PICTURE_COUNT; in ff_mpeg_update_thread_context()
78 ff_mpv_idct_init(s); in ff_mpeg_update_thread_context()
79 if ((err = ff_mpv_common_init(s)) < 0) { in ff_mpeg_update_thread_context()
80 memset(s, 0, sizeof(*s)); in ff_mpeg_update_thread_context()
81 s->avctx = dst; in ff_mpeg_update_thread_context()
82 s->private_ctx = private_ctx; in ff_mpeg_update_thread_context()
88 if (s->height != s1->height || s->width != s1->width || s->context_reinit) { in ff_mpeg_update_thread_context()
89 s->height = s1->height; in ff_mpeg_update_thread_context()
90 s->width = s1->width; in ff_mpeg_update_thread_context()
91 if ((ret = ff_mpv_common_frame_size_change(s)) < 0) in ff_mpeg_update_thread_context()
95 s->avctx->coded_height = s1->avctx->coded_height; in ff_mpeg_update_thread_context()
96 s->avctx->coded_width = s1->avctx->coded_width; in ff_mpeg_update_thread_context()
97 s->avctx->width = s1->avctx->width; in ff_mpeg_update_thread_context()
98 s->avctx->height = s1->avctx->height; in ff_mpeg_update_thread_context()
100 s->quarter_sample = s1->quarter_sample; in ff_mpeg_update_thread_context()
102 s->coded_picture_number = s1->coded_picture_number; in ff_mpeg_update_thread_context()
103 s->picture_number = s1->picture_number; in ff_mpeg_update_thread_context()
105 av_assert0(!s->picture || s->picture != s1->picture); in ff_mpeg_update_thread_context()
106 if (s->picture) in ff_mpeg_update_thread_context()
108 ff_mpeg_unref_picture(s->avctx, &s->picture[i]); in ff_mpeg_update_thread_context()
110 (ret = ff_mpeg_ref_picture(s->avctx, &s->picture[i], &s1->picture[i])) < 0) in ff_mpeg_update_thread_context()
116 ff_mpeg_unref_picture(s->avctx, &s->pic);\ in ff_mpeg_update_thread_context()
118 ret = ff_mpeg_ref_picture(s->avctx, &s->pic, &s1->pic);\ in ff_mpeg_update_thread_context()
120 ret = ff_update_picture_tables(&s->pic, &s1->pic);\ in ff_mpeg_update_thread_context()
134 s->last_picture_ptr = REBASE_PICTURE(s1->last_picture_ptr, s, s1); in ff_mpeg_update_thread_context()
135 s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, s, s1); in ff_mpeg_update_thread_context()
136 s->next_picture_ptr = REBASE_PICTURE(s1->next_picture_ptr, s, s1); in ff_mpeg_update_thread_context()
139 s->workaround_bugs = s1->workaround_bugs; in ff_mpeg_update_thread_context()
140 s->padding_bug_score = s1->padding_bug_score; in ff_mpeg_update_thread_context()
143 memcpy(&s->last_time_base, &s1->last_time_base, in ff_mpeg_update_thread_context()
148 s->max_b_frames = s1->max_b_frames; in ff_mpeg_update_thread_context()
149 s->low_delay = s1->low_delay; in ff_mpeg_update_thread_context()
150 s->droppable = s1->droppable; in ff_mpeg_update_thread_context()
153 s->divx_packed = s1->divx_packed; in ff_mpeg_update_thread_context()
157 AV_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size) { in ff_mpeg_update_thread_context()
158 av_fast_malloc(&s->bitstream_buffer, in ff_mpeg_update_thread_context()
159 &s->allocated_bitstream_buffer_size, in ff_mpeg_update_thread_context()
161 if (!s->bitstream_buffer) { in ff_mpeg_update_thread_context()
162 s->bitstream_buffer_size = 0; in ff_mpeg_update_thread_context()
166 s->bitstream_buffer_size = s1->bitstream_buffer_size; in ff_mpeg_update_thread_context()
167 memcpy(s->bitstream_buffer, s1->bitstream_buffer, in ff_mpeg_update_thread_context()
169 memset(s->bitstream_buffer + s->bitstream_buffer_size, 0, in ff_mpeg_update_thread_context()
174 if (!s->sc.edge_emu_buffer) in ff_mpeg_update_thread_context()
176 if (ff_mpeg_framesize_alloc(s->avctx, &s->me, in ff_mpeg_update_thread_context()
177 &s->sc, s1->linesize) < 0) { in ff_mpeg_update_thread_context()
178 av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate context " in ff_mpeg_update_thread_context()
183 av_log(s->avctx, AV_LOG_ERROR, "Context scratch buffers could not " in ff_mpeg_update_thread_context()
188 memcpy(&s->progressive_sequence, &s1->progressive_sequence, in ff_mpeg_update_thread_context()
194 int ff_mpv_common_frame_size_change(MpegEncContext *s) in ff_mpv_common_frame_size_change() argument
198 if (!s->context_initialized) in ff_mpv_common_frame_size_change()
201 ff_mpv_free_context_frame(s); in ff_mpv_common_frame_size_change()
203 if (s->picture) in ff_mpv_common_frame_size_change()
205 s->picture[i].needs_realloc = 1; in ff_mpv_common_frame_size_change()
207 s->last_picture_ptr = in ff_mpv_common_frame_size_change()
208 s->next_picture_ptr = in ff_mpv_common_frame_size_change()
209 s->current_picture_ptr = NULL; in ff_mpv_common_frame_size_change()
212 if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence) in ff_mpv_common_frame_size_change()
213 s->mb_height = (s->height + 31) / 32 * 2; in ff_mpv_common_frame_size_change()
215 s->mb_height = (s->height + 15) / 16; in ff_mpv_common_frame_size_change()
217 if ((s->width || s->height) && in ff_mpv_common_frame_size_change()
218 (err = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0) in ff_mpv_common_frame_size_change()
222 err = av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, in ff_mpv_common_frame_size_change()
223 &s->chroma_x_shift, in ff_mpv_common_frame_size_change()
224 &s->chroma_y_shift); in ff_mpv_common_frame_size_change()
228 if ((err = ff_mpv_init_context_frame(s))) in ff_mpv_common_frame_size_change()
231 memset(s->thread_context, 0, sizeof(s->thread_context)); in ff_mpv_common_frame_size_change()
232 s->thread_context[0] = s; in ff_mpv_common_frame_size_change()
234 if (s->width && s->height) { in ff_mpv_common_frame_size_change()
235 err = ff_mpv_init_duplicate_contexts(s); in ff_mpv_common_frame_size_change()
239 s->context_reinit = 0; in ff_mpv_common_frame_size_change()
243 ff_mpv_free_context_frame(s); in ff_mpv_common_frame_size_change()
244 s->context_reinit = 1; in ff_mpv_common_frame_size_change()
248 static int alloc_picture(MpegEncContext *s, Picture *pic) in alloc_picture() argument
250 return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, 0, 0, in alloc_picture()
251 s->chroma_x_shift, s->chroma_y_shift, s->out_format, in alloc_picture()
252 s->mb_stride, s->mb_width, s->mb_height, s->b8_stride, in alloc_picture()
253 &s->linesize, &s->uvlinesize); in alloc_picture()
276 int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) in ff_mpv_frame_start() argument
281 s->mb_skipped = 0; in ff_mpv_frame_start()
289 if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && in ff_mpv_frame_start()
290 s->last_picture_ptr != s->next_picture_ptr && in ff_mpv_frame_start()
291 s->last_picture_ptr->f->buf[0]) { in ff_mpv_frame_start()
292 ff_mpeg_unref_picture(s->avctx, s->last_picture_ptr); in ff_mpv_frame_start()
298 if (&s->picture[i] != s->last_picture_ptr && in ff_mpv_frame_start()
299 &s->picture[i] != s->next_picture_ptr && in ff_mpv_frame_start()
300 s->picture[i].reference && !s->picture[i].needs_realloc) { in ff_mpv_frame_start()
301 ff_mpeg_unref_picture(s->avctx, &s->picture[i]); in ff_mpv_frame_start()
305 ff_mpeg_unref_picture(s->avctx, &s->current_picture); in ff_mpv_frame_start()
306 ff_mpeg_unref_picture(s->avctx, &s->last_picture); in ff_mpv_frame_start()
307 ff_mpeg_unref_picture(s->avctx, &s->next_picture); in ff_mpv_frame_start()
311 if (!s->picture[i].reference) in ff_mpv_frame_start()
312 ff_mpeg_unref_picture(s->avctx, &s->picture[i]); in ff_mpv_frame_start()
315 if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) { in ff_mpv_frame_start()
318 pic = s->current_picture_ptr; in ff_mpv_frame_start()
320 idx = ff_find_unused_picture(s->avctx, s->picture, 0); in ff_mpv_frame_start()
322 av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); in ff_mpv_frame_start()
325 pic = &s->picture[idx]; in ff_mpv_frame_start()
329 if (!s->droppable) { in ff_mpv_frame_start()
330 if (s->pict_type != AV_PICTURE_TYPE_B) in ff_mpv_frame_start()
334 pic->f->coded_picture_number = s->coded_picture_number++; in ff_mpv_frame_start()
336 if (alloc_picture(s, pic) < 0) in ff_mpv_frame_start()
339 s->current_picture_ptr = pic; in ff_mpv_frame_start()
341 s->current_picture_ptr->f->top_field_first = s->top_field_first; in ff_mpv_frame_start()
342 if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO || in ff_mpv_frame_start()
343 s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { in ff_mpv_frame_start()
344 if (s->picture_structure != PICT_FRAME) in ff_mpv_frame_start()
345 s->current_picture_ptr->f->top_field_first = in ff_mpv_frame_start()
346 (s->picture_structure == PICT_TOP_FIELD) == s->first_field; in ff_mpv_frame_start()
348 s->current_picture_ptr->f->interlaced_frame = !s->progressive_frame && in ff_mpv_frame_start()
349 !s->progressive_sequence; in ff_mpv_frame_start()
350 s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME; in ff_mpv_frame_start()
352 s->current_picture_ptr->f->pict_type = s->pict_type; in ff_mpv_frame_start()
353 s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I; in ff_mpv_frame_start()
355 if ((ret = ff_mpeg_ref_picture(s->avctx, &s->current_picture, in ff_mpv_frame_start()
356 s->current_picture_ptr)) < 0) in ff_mpv_frame_start()
359 if (s->pict_type != AV_PICTURE_TYPE_B) { in ff_mpv_frame_start()
360 s->last_picture_ptr = s->next_picture_ptr; in ff_mpv_frame_start()
361 if (!s->droppable) in ff_mpv_frame_start()
362 s->next_picture_ptr = s->current_picture_ptr; in ff_mpv_frame_start()
364 ff_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", in ff_mpv_frame_start()
365 s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr, in ff_mpv_frame_start()
366 s->last_picture_ptr ? s->last_picture_ptr->f->data[0] : NULL, in ff_mpv_frame_start()
367 s->next_picture_ptr ? s->next_picture_ptr->f->data[0] : NULL, in ff_mpv_frame_start()
368 s->current_picture_ptr ? s->current_picture_ptr->f->data[0] : NULL, in ff_mpv_frame_start()
369 s->pict_type, s->droppable); in ff_mpv_frame_start()
371 if ((!s->last_picture_ptr || !s->last_picture_ptr->f->buf[0]) && in ff_mpv_frame_start()
372 (s->pict_type != AV_PICTURE_TYPE_I)) { in ff_mpv_frame_start()
374 av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, in ff_mpv_frame_start()
376 … if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f->buf[0]) in ff_mpv_frame_start()
379 else if (s->pict_type != AV_PICTURE_TYPE_I) in ff_mpv_frame_start()
384 idx = ff_find_unused_picture(s->avctx, s->picture, 0); in ff_mpv_frame_start()
386 av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); in ff_mpv_frame_start()
389 s->last_picture_ptr = &s->picture[idx]; in ff_mpv_frame_start()
391 s->last_picture_ptr->reference = 3; in ff_mpv_frame_start()
392 s->last_picture_ptr->f->key_frame = 0; in ff_mpv_frame_start()
393 s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P; in ff_mpv_frame_start()
395 if (alloc_picture(s, s->last_picture_ptr) < 0) { in ff_mpv_frame_start()
396 s->last_picture_ptr = NULL; in ff_mpv_frame_start()
402 memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0]*i, in ff_mpv_frame_start()
404 if (s->last_picture_ptr->f->data[2]) { in ff_mpv_frame_start()
406 memset(s->last_picture_ptr->f->data[1] + s->last_picture_ptr->f->linesize[1]*i, in ff_mpv_frame_start()
408 memset(s->last_picture_ptr->f->data[2] + s->last_picture_ptr->f->linesize[2]*i, in ff_mpv_frame_start()
413 if (s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263) { in ff_mpv_frame_start()
415 … memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0] * i, in ff_mpv_frame_start()
420 ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0); in ff_mpv_frame_start()
421 ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1); in ff_mpv_frame_start()
423 if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) && in ff_mpv_frame_start()
424 s->pict_type == AV_PICTURE_TYPE_B) { in ff_mpv_frame_start()
426 idx = ff_find_unused_picture(s->avctx, s->picture, 0); in ff_mpv_frame_start()
428 av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); in ff_mpv_frame_start()
431 s->next_picture_ptr = &s->picture[idx]; in ff_mpv_frame_start()
433 s->next_picture_ptr->reference = 3; in ff_mpv_frame_start()
434 s->next_picture_ptr->f->key_frame = 0; in ff_mpv_frame_start()
435 s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P; in ff_mpv_frame_start()
437 if (alloc_picture(s, s->next_picture_ptr) < 0) { in ff_mpv_frame_start()
438 s->next_picture_ptr = NULL; in ff_mpv_frame_start()
441 ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 0); in ff_mpv_frame_start()
442 ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 1); in ff_mpv_frame_start()
446 memset(s->last_picture.f->data, 0, sizeof(s->last_picture.f->data)); in ff_mpv_frame_start()
447 memset(s->next_picture.f->data, 0, sizeof(s->next_picture.f->data)); in ff_mpv_frame_start()
449 if (s->last_picture_ptr) { in ff_mpv_frame_start()
450 if (s->last_picture_ptr->f->buf[0] && in ff_mpv_frame_start()
451 (ret = ff_mpeg_ref_picture(s->avctx, &s->last_picture, in ff_mpv_frame_start()
452 s->last_picture_ptr)) < 0) in ff_mpv_frame_start()
455 if (s->next_picture_ptr) { in ff_mpv_frame_start()
456 if (s->next_picture_ptr->f->buf[0] && in ff_mpv_frame_start()
457 (ret = ff_mpeg_ref_picture(s->avctx, &s->next_picture, in ff_mpv_frame_start()
458 s->next_picture_ptr)) < 0) in ff_mpv_frame_start()
462 av_assert0(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr && in ff_mpv_frame_start()
463 s->last_picture_ptr->f->buf[0])); in ff_mpv_frame_start()
465 if (s->picture_structure != PICT_FRAME) { in ff_mpv_frame_start()
467 if (s->picture_structure == PICT_BOTTOM_FIELD) { in ff_mpv_frame_start()
468 s->current_picture.f->data[i] += in ff_mpv_frame_start()
469 s->current_picture.f->linesize[i]; in ff_mpv_frame_start()
471 s->current_picture.f->linesize[i] *= 2; in ff_mpv_frame_start()
472 s->last_picture.f->linesize[i] *= 2; in ff_mpv_frame_start()
473 s->next_picture.f->linesize[i] *= 2; in ff_mpv_frame_start()
480 if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { in ff_mpv_frame_start()
481 s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra; in ff_mpv_frame_start()
482 s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter; in ff_mpv_frame_start()
483 } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) { in ff_mpv_frame_start()
484 s->dct_unquantize_intra = s->dct_unquantize_h263_intra; in ff_mpv_frame_start()
485 s->dct_unquantize_inter = s->dct_unquantize_h263_inter; in ff_mpv_frame_start()
487 s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra; in ff_mpv_frame_start()
488 s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter; in ff_mpv_frame_start()
491 if (s->avctx->debug & FF_DEBUG_NOMC) in ff_mpv_frame_start()
492 gray_frame(s->current_picture_ptr->f); in ff_mpv_frame_start()
498 void ff_mpv_frame_end(MpegEncContext *s) in ff_mpv_frame_end() argument
502 if (s->current_picture.reference) in ff_mpv_frame_end()
503 ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0); in ff_mpv_frame_end()
506 void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict) in ff_print_debug_info() argument
508 ff_print_debug_info2(s->avctx, pict, s->mbskip_table, p->mb_type, in ff_print_debug_info()
510 s->mb_width, s->mb_height, s->mb_stride, s->quarter_sample); in ff_print_debug_info()
513 int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type) in ff_mpv_export_qp_table() argument
519 if (!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS)) in ff_mpv_export_qp_table()
543 void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h) in ff_mpeg_draw_horiz_band() argument
545 ff_draw_horiz_band(s->avctx, s->current_picture_ptr->f, in ff_mpeg_draw_horiz_band()
546 s->last_picture_ptr ? s->last_picture_ptr->f : NULL, in ff_mpeg_draw_horiz_band()
547 y, h, s->picture_structure, in ff_mpeg_draw_horiz_band()
548 s->first_field, s->low_delay); in ff_mpeg_draw_horiz_band()
553 MpegEncContext *const s = avctx->priv_data; in ff_mpeg_flush() local
555 if (!s->picture) in ff_mpeg_flush()
559 ff_mpeg_unref_picture(s->avctx, &s->picture[i]); in ff_mpeg_flush()
560 s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL; in ff_mpeg_flush()
562 ff_mpeg_unref_picture(s->avctx, &s->current_picture); in ff_mpeg_flush()
563 ff_mpeg_unref_picture(s->avctx, &s->last_picture); in ff_mpeg_flush()
564 ff_mpeg_unref_picture(s->avctx, &s->next_picture); in ff_mpeg_flush()
566 s->mb_x = s->mb_y = 0; in ff_mpeg_flush()
569 s->parse_context.state = -1; in ff_mpeg_flush()
570 s->parse_context.frame_start_found = 0; in ff_mpeg_flush()
571 s->parse_context.overread = 0; in ff_mpeg_flush()
572 s->parse_context.overread_index = 0; in ff_mpeg_flush()
573 s->parse_context.index = 0; in ff_mpeg_flush()
574 s->parse_context.last_index = 0; in ff_mpeg_flush()
576 s->bitstream_buffer_size = 0; in ff_mpeg_flush()
577 s->pp_time = 0; in ff_mpeg_flush()
580 void ff_mpv_report_decode_progress(MpegEncContext *s) in ff_mpv_report_decode_progress() argument
582 if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred) in ff_mpv_report_decode_progress()
583 ff_thread_report_progress(&s->current_picture_ptr->tf, s->mb_y, 0); in ff_mpv_report_decode_progress()