Skip to content

Commit

Permalink
Merge pull request #5 from mitzsch/ad_spdif_pr2
Browse files Browse the repository at this point in the history
ad_spdif: change deprecated FF_PROFILE to AV_PROFILE
  • Loading branch information
mitzsch authored Jan 26, 2024
2 parents de92fb2 + 215e9d7 commit 778e1c3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions audio/decode/ad_spdif.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavcodec/defs.h>
#include <libavutil/opt.h>

#include "audio/aframe.h"
Expand Down Expand Up @@ -90,7 +91,7 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt,
int *out_profile, int *out_rate)
{
struct spdifContext *spdif_ctx = da->priv;
int profile = FF_PROFILE_UNKNOWN;
int profile = AV_PROFILE_UNKNOWN;
AVCodecContext *ctx = NULL;
AVFrame *frame = NULL;

Expand All @@ -115,7 +116,7 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt,
av_parser_close(parser);
}

if (profile != FF_PROFILE_UNKNOWN || spdif_ctx->codec_id != AV_CODEC_ID_DTS)
if (profile != AV_PROFILE_UNKNOWN || spdif_ctx->codec_id != AV_CODEC_ID_DTS)
return;

const AVCodec *codec = avcodec_find_decoder(spdif_ctx->codec_id);
Expand Down Expand Up @@ -145,7 +146,7 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt,
av_frame_free(&frame);
avcodec_free_context(&ctx);

if (profile == FF_PROFILE_UNKNOWN)
if (profile == AV_PROFILE_UNKNOWN)
MP_WARN(da, "Failed to parse codec profile.\n");
}

Expand All @@ -155,7 +156,7 @@ static int init_filter(struct mp_filter *da)

AVPacket *pkt = spdif_ctx->avpkt;

int profile = FF_PROFILE_UNKNOWN;
int profile = AV_PROFILE_UNKNOWN;
int c_rate = 0;
determine_codec_params(da, pkt, &profile, &c_rate);
MP_VERBOSE(da, "In: profile=%d samplerate=%d\n", profile, c_rate);
Expand Down Expand Up @@ -208,15 +209,15 @@ static int init_filter(struct mp_filter *da)
num_channels = 2;
break;
case AV_CODEC_ID_DTS: {
bool is_hd = profile == FF_PROFILE_DTS_HD_HRA ||
profile == FF_PROFILE_DTS_HD_MA ||
profile == FF_PROFILE_UNKNOWN;
bool is_hd = profile == AV_PROFILE_DTS_HD_HRA ||
profile == AV_PROFILE_DTS_HD_MA ||
profile == AV_PROFILE_UNKNOWN;

// Apparently, DTS-HD over SPDIF is specified to be 7.1 (8 channels)
// for DTS-HD MA, and stereo (2 channels) for DTS-HD HRA. The bit
// streaming rate as well as the signaled channel count are defined
// based on this value.
int dts_hd_spdif_channel_count = profile == FF_PROFILE_DTS_HD_HRA ?
int dts_hd_spdif_channel_count = profile == AV_PROFILE_DTS_HD_HRA ?
2 : 8;
if (spdif_ctx->use_dts_hd && is_hd) {
av_dict_set_int(&format_opts, "dtshd_rate",
Expand Down

0 comments on commit 778e1c3

Please sign in to comment.