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
249249 // Handle Video Frame
250250 if (videoFrame) {
251251 AVPacket pkt;
252− AVCodecContext *c;
253252 av_init_packet(&pkt);
254− c = ctx->video_st->codec;
255253 if (ctx->frameCount % 25 == 0) {
256254 unsigned long long qsize = avpacket_queue_size(&ctx->queue);
257255 av_log(avctx, AV_LOG_DEBUG,
@@ -354,7 +352,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 96 unmodified lines
354352 }
355353 #endif
356354
357− c->frame_number++;
358355 if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
359356 ++ctx->dropped;
360357 }
@@ -362,14 +359,12 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 1 unmodified line
362359
363360 // Handle Audio Frame
364361 if (audioFrame) {
365− AVCodecContext *c;
366362 AVPacket pkt;
367363 BMDTimeValue audio_pts;
368364 av_init_packet(&pkt);
369365
370− c = ctx->audio_st->codec;
371366 //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);
373368 audioFrame->GetBytes(&audioFrameBytes);
374369 audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den);
375370 pkt.pts = audio_pts / ctx->audio_st->time_base.num;
@@ -386,7 +381,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 10 unmodified lines
386381 pkt.stream_index = ctx->audio_st->index;
387382 pkt.data = (uint8_t *)audioFrameBytes;
388383
389− c->frame_number++;
390384 if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
391385 ++ctx->dropped;
392386 }
@@ -551,10 +545,10 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 158 unmodified lines
551545 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
552546 goto error;
553547 }
554− st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
555− st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
556− st->codec->sample_rate = bmdAudioSampleRate48kHz;
557− st->codec->channels = cctx->audio_channels;
548+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
549+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
550+ st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
551+ st->codecpar->channels = cctx->audio_channels;
558552 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
559553 ctx->audio_st=st;
560554
@@ -563,21 +557,21 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 2 unmodified lines
563557 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
564558 goto error;
565559 }
566− st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
567− st->codec->width = ctx->bmd_width;
568− st->codec->height = ctx->bmd_height;
560+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
561+ st->codecpar->width = ctx->bmd_width;
562+ st->codecpar->height = ctx->bmd_height;
569563
570− st->codec->time_base.den = ctx->bmd_tb_den;
571− st->codec->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;
564+ st->time_base.den = ctx->bmd_tb_den;
565+ st->time_base.num = ctx->bmd_tb_num;
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;
573567
574568 if (cctx->v210) {
575− st->codec->codec_id = AV_CODEC_ID_V210;
576− st->codec->codec_tag = MKTAG('V', '2', '1', '0');
569+ st->codecpar->codec_id = AV_CODEC_ID_V210;
570+ st->codecpar->codec_tag = MKTAG('V', '2', '1', '0');
577571 } else {
578− st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
579− st->codec->pix_fmt = AV_PIX_FMT_UYVY422;
580− st->codec->codec_tag = MKTAG('U', 'Y', 'V', 'Y');
572+ st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
573+ st->codecpar->format = AV_PIX_FMT_UYVY422;
574+ st->codecpar->codec_tag = MKTAG('U', 'Y', 'V', 'Y');
581575 }
582576
583577 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
590584 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
591585 goto error;
592586 }
593− st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
594− st->codec->time_base.den = ctx->bmd_tb_den;
595− st->codec->time_base.num = ctx->bmd_tb_num;
596− st->codec->codec_id = AV_CODEC_ID_DVB_TELETEXT;
587+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
588+ st->time_base.den = ctx->bmd_tb_den;
589+ st->time_base.num = ctx->bmd_tb_num;
590+ st->codecpar->codec_id = AV_CODEC_ID_DVB_TELETEXT;
597591 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
598592 ctx->teletext_st = st;
599593 }
600594
601− av_log(avctx, AV_LOG_VERBOSE, "Using %d input audio channels\n", ctx->audio_st->codec->channels);
602− result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, ctx->audio_st->codec->channels);
595+ av_log(avctx, AV_LOG_VERBOSE, "Using %d input audio channels\n", ctx->audio_st->codecpar->channels);
596+ result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, ctx->audio_st->codecpar->channels);
603597
604598 if (result != S_OK) {
605599 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