Signed-off-by: Marton Balint <cus@passwd.hu>
Dave Rice authored on 2017/10/19 04:21:46... | ... |
@@ -311,6 +311,10 @@ Sets maximum input buffer size in bytes. If the buffering reaches this value, |
311 | 311 |
incoming frames will be dropped. |
312 | 312 |
Defaults to @samp{1073741824}. |
313 | 313 |
|
314 |
+@item audio_depth |
|
315 |
+Sets the audio sample bit depth. Must be @samp{16} or @samp{32}. |
|
316 |
+Defaults to @samp{16}. |
|
317 |
+ |
|
314 | 318 |
@end table |
315 | 319 |
|
316 | 320 |
@subsection Examples |
... | ... |
@@ -771,7 +771,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( |
771 | 771 |
av_init_packet(&pkt); |
772 | 772 |
|
773 | 773 |
//hack among hacks |
774 |
- pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (16 / 8); |
|
774 |
+ pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (ctx->audio_depth / 8); |
|
775 | 775 |
audioFrame->GetBytes(&audioFrameBytes); |
776 | 776 |
audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den); |
777 | 777 |
pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, ctx->audio_pts_source, ctx->audio_st->time_base, &initial_audio_pts); |
... | ... |
@@ -854,6 +854,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) |
854 | 854 |
ctx->audio_pts_source = cctx->audio_pts_source; |
855 | 855 |
ctx->video_pts_source = cctx->video_pts_source; |
856 | 856 |
ctx->draw_bars = cctx->draw_bars; |
857 |
+ ctx->audio_depth = cctx->audio_depth; |
|
857 | 858 |
cctx->ctx = ctx; |
858 | 859 |
|
859 | 860 |
/* Check audio channel option for valid values: 2, 8 or 16 */ |
... | ... |
@@ -867,6 +868,16 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) |
867 | 867 |
return AVERROR(EINVAL); |
868 | 868 |
} |
869 | 869 |
|
870 |
+ /* Check audio bit depth option for valid values: 16 or 32 */ |
|
871 |
+ switch (cctx->audio_depth) { |
|
872 |
+ case 16: |
|
873 |
+ case 32: |
|
874 |
+ break; |
|
875 |
+ default: |
|
876 |
+ av_log(avctx, AV_LOG_ERROR, "Value for audio bit depth option must be either 16 or 32\n"); |
|
877 |
+ return AVERROR(EINVAL); |
|
878 |
+ } |
|
879 |
+ |
|
870 | 880 |
/* List available devices. */ |
871 | 881 |
if (ctx->list_devices) { |
872 | 882 |
ff_decklink_list_devices_legacy(avctx, 1, 0); |
... | ... |
@@ -930,7 +941,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) |
930 | 930 |
goto error; |
931 | 931 |
} |
932 | 932 |
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; |
933 |
- st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; |
|
933 |
+ st->codecpar->codec_id = cctx->audio_depth == 32 ? AV_CODEC_ID_PCM_S32LE : AV_CODEC_ID_PCM_S16LE; |
|
934 | 934 |
st->codecpar->sample_rate = bmdAudioSampleRate48kHz; |
935 | 935 |
st->codecpar->channels = cctx->audio_channels; |
936 | 936 |
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ |
... | ... |
@@ -1021,7 +1032,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) |
1021 | 1021 |
} |
1022 | 1022 |
|
1023 | 1023 |
av_log(avctx, AV_LOG_VERBOSE, "Using %d input audio channels\n", ctx->audio_st->codecpar->channels); |
1024 |
- result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, ctx->audio_st->codecpar->channels); |
|
1024 |
+ result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, cctx->audio_depth == 32 ? bmdAudioSampleType32bitInteger : bmdAudioSampleType16bitInteger, ctx->audio_st->codecpar->channels); |
|
1025 | 1025 |
|
1026 | 1026 |
if (result != S_OK) { |
1027 | 1027 |
av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n"); |
... | ... |
@@ -72,6 +72,7 @@ static const AVOption options[] = { |
72 | 72 |
{ "wallclock", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_WALLCLOCK}, 0, 0, DEC, "pts_source"}, |
73 | 73 |
{ "draw_bars", "draw bars on signal loss" , OFFSET(draw_bars), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, DEC }, |
74 | 74 |
{ "queue_size", "input queue buffer size", OFFSET(queue_size), AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC }, |
75 |
+ { "audio_depth", "audio bitdepth (16 or 32)", OFFSET(audio_depth), AV_OPT_TYPE_INT, { .i64 = 16}, 16, 32, DEC }, |
|
75 | 76 |
{ NULL }, |
76 | 77 |
}; |
77 | 78 |
|
... | ... |
@@ -29,7 +29,7 @@ |
29 | 29 |
|
30 | 30 |
#define LIBAVDEVICE_VERSION_MAJOR 57 |
31 | 31 |
#define LIBAVDEVICE_VERSION_MINOR 11 |
32 |
-#define LIBAVDEVICE_VERSION_MICRO 100 |
|
32 |
+#define LIBAVDEVICE_VERSION_MICRO 101 |
|
33 | 33 |
|
34 | 34 |
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ |
35 | 35 |
LIBAVDEVICE_VERSION_MINOR, \ |