History

avdevice/decklink_dec: Convert decklink input module to use codecpar

There are still a couple of deprecated calls that I’m not sure what to do with. They are both related to some logic around AVCodecContext.coded_frame. I couldn’t find anywhere that really documented what that was, or where it was intended to move to. I left the warnings on.

Felt, Patrick committed 10 years ago

Commit fce75131 parent ea791c01 file · +22 −28Browse files

Showing the changes to libavdevice/decklink_dec.cpp (1 of 1 file). Show all

Unified · Split

libavdevice/decklink_dec.cpp+22−28
@@ -249,9 +249,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 248 unmodified lines
249 // Handle Video Frame249 // Handle Video Frame
250 if (videoFrame) {250 if (videoFrame) {
251 AVPacket pkt;251 AVPacket pkt;
252 AVCodecContext *c;
253 av_init_packet(&pkt);252 av_init_packet(&pkt);
254 c = ctx->video_st->codec;
255 if (ctx->frameCount % 25 == 0) {253 if (ctx->frameCount % 25 == 0) {
256 unsigned long long qsize = avpacket_queue_size(&ctx->queue);254 unsigned long long qsize = avpacket_queue_size(&ctx->queue);
257 av_log(avctx, AV_LOG_DEBUG,255 av_log(avctx, AV_LOG_DEBUG,
@@ -354,7 +352,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 96 unmodified lines
354 }352 }
355#endif353#endif
356 354
357 c->frame_number++;
358 if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {355 if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
359 ++ctx->dropped;356 ++ctx->dropped;
360 }357 }
@@ -362,14 +359,12 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 1 unmodified line
362 359
363 // Handle Audio Frame360 // Handle Audio Frame
364 if (audioFrame) {361 if (audioFrame) {
365 AVCodecContext *c;
366 AVPacket pkt;362 AVPacket pkt;
367 BMDTimeValue audio_pts;363 BMDTimeValue audio_pts;
368 av_init_packet(&pkt);364 av_init_packet(&pkt);
369 365
370 c = ctx->audio_st->codec;
371 //hack among hacks366 //hack among hacks
372 pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codec->channels * (16 / 8);367 pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (16 / 8);
373 audioFrame->GetBytes(&audioFrameBytes);368 audioFrame->GetBytes(&audioFrameBytes);
374 audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den);369 audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den);
375 pkt.pts = audio_pts / ctx->audio_st->time_base.num;370 pkt.pts = audio_pts / ctx->audio_st->time_base.num;
@@ -386,7 +381,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 10 unmodified lines
386 pkt.stream_index = ctx->audio_st->index;381 pkt.stream_index = ctx->audio_st->index;
387 pkt.data = (uint8_t *)audioFrameBytes;382 pkt.data = (uint8_t *)audioFrameBytes;
388 383
389 c->frame_number++;
390 if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {384 if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
391 ++ctx->dropped;385 ++ctx->dropped;
392 }386 }
@@ -551,10 +545,10 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 158 unmodified lines
551 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");545 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
552 goto error;546 goto error;
553 }547 }
554 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;548 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
555 st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;549 st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
556 st->codec->sample_rate = bmdAudioSampleRate48kHz;550 st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
557 st->codec->channels = cctx->audio_channels;551 st->codecpar->channels = cctx->audio_channels;
558 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */552 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
559 ctx->audio_st=st;553 ctx->audio_st=st;
560 554
@@ -563,21 +557,21 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 2 unmodified lines
563 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");557 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
564 goto error;558 goto error;
565 }559 }
566 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;560 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
567 st->codec->width = ctx->bmd_width;561 st->codecpar->width = ctx->bmd_width;
568 st->codec->height = ctx->bmd_height;562 st->codecpar->height = ctx->bmd_height;
569 563
570 st->codec->time_base.den = ctx->bmd_tb_den;564 st->time_base.den = ctx->bmd_tb_den;
571 st->codec->time_base.num = ctx->bmd_tb_num;565 st->time_base.num = ctx->bmd_tb_num;
572 st->codec->bit_rate = av_image_get_buffer_size(st->codec->pix_fmt, ctx->bmd_width, ctx->bmd_height, 1) * 1/av_q2d(st->codec->time_base) * 8;566 st->codecpar->bit_rate = av_image_get_buffer_size((AVPixelFormat)st->codecpar->format, ctx->bmd_width, ctx->bmd_height, 1) * 1/av_q2d(st->time_base) * 8;
573 567
574 if (cctx->v210) {568 if (cctx->v210) {
575 st->codec->codec_id = AV_CODEC_ID_V210;569 st->codecpar->codec_id = AV_CODEC_ID_V210;
576 st->codec->codec_tag = MKTAG('V', '2', '1', '0');570 st->codecpar->codec_tag = MKTAG('V', '2', '1', '0');
577 } else {571 } else {
578 st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;572 st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
579 st->codec->pix_fmt = AV_PIX_FMT_UYVY422;573 st->codecpar->format = AV_PIX_FMT_UYVY422;
580 st->codec->codec_tag = MKTAG('U', 'Y', 'V', 'Y');574 st->codecpar->codec_tag = MKTAG('U', 'Y', 'V', 'Y');
581 }575 }
582 576
583 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */577 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
@@ -590,16 +584,16 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 6 unmodified lines
590 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");584 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
591 goto error;585 goto error;
592 }586 }
593 st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;587 st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
594 st->codec->time_base.den = ctx->bmd_tb_den;588 st->time_base.den = ctx->bmd_tb_den;
595 st->codec->time_base.num = ctx->bmd_tb_num;589 st->time_base.num = ctx->bmd_tb_num;
596 st->codec->codec_id = AV_CODEC_ID_DVB_TELETEXT;590 st->codecpar->codec_id = AV_CODEC_ID_DVB_TELETEXT;
597 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */591 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
598 ctx->teletext_st = st;592 ctx->teletext_st = st;
599 }593 }
600 594
601 av_log(avctx, AV_LOG_VERBOSE, "Using %d input audio channels\n", ctx->audio_st->codec->channels);595 av_log(avctx, AV_LOG_VERBOSE, "Using %d input audio channels\n", ctx->audio_st->codecpar->channels);
602 result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, ctx->audio_st->codec->channels);596 result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, ctx->audio_st->codecpar->channels);
603 597
604 if (result != S_OK) {598 if (result != S_OK) {
605 av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");599 av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t