Skip to content

Commit 5664758

Browse files
Add support for ffmpeg 8 (#39)
* fix: change FF_PROFILE_UNKNOWN to AV_PROFILE_UNKNOWN in ffmpeg8 * refactor: define profile centrally in utils.h
1 parent b7efda3 commit 5664758

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

c_src/xav/decoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ int decoder_flush(struct Decoder *decoder, AVFrame **frames, int *frames_count);
2525

2626
void decoder_free_frame(struct Decoder *decoder);
2727

28-
void decoder_free(struct Decoder **decoder);
28+
void decoder_free(struct Decoder **decoder);

c_src/xav/encoder.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int encoder_init(struct Encoder *encoder, struct EncoderConfig *config) {
4242
xav_set_channel_layout(encoder->c, &config->channel_layout);
4343
}
4444

45-
if (config->profile != FF_PROFILE_UNKNOWN) {
45+
if (config->profile != AV_PROFILE_UNKNOWN) {
4646
encoder->c->profile = config->profile;
4747
}
4848

@@ -107,4 +107,4 @@ void encoder_free(struct Encoder **encoder) {
107107
XAV_FREE(e);
108108
*encoder = NULL;
109109
}
110-
}
110+
}

c_src/xav/utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
#include <libswresample/swresample.h>
88
#include <libswscale/swscale.h>
99

10+
// FFmpeg ≤ 7 used FF_PROFILE_UNKNOWN, FFmpeg ≥ 8 uses AV_PROFILE_UNKNOWN
11+
#ifndef AV_PROFILE_UNKNOWN
12+
#define AV_PROFILE_UNKNOWN FF_PROFILE_UNKNOWN
13+
#endif
14+
1015
#ifdef XAV_DEBUG
1116
#define XAV_LOG_DEBUG(X, ...) \
1217
fprintf(stderr, "[XAV DEBUG %s] %s:%d " X "\n", __TIME__, __FILE__, __LINE__, ##__VA_ARGS__)

c_src/xav/xav_encoder.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ERL_NIF_TERM new (ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) {
1818
ERL_NIF_TERM ret;
1919
struct EncoderConfig encoder_config = {0};
2020
encoder_config.max_b_frames = -1;
21-
encoder_config.profile = FF_PROFILE_UNKNOWN;
21+
encoder_config.profile = AV_PROFILE_UNKNOWN;
2222

2323
char *codec_name = NULL, *format = NULL, *profile = NULL;
2424
char *channel_layout = NULL;
@@ -112,7 +112,7 @@ ERL_NIF_TERM new (ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) {
112112

113113
if (profile) {
114114
encoder_config.profile = get_profile(encoder_config.codec->id, profile);
115-
if (encoder_config.profile == FF_PROFILE_UNKNOWN) {
115+
if (encoder_config.profile == AV_PROFILE_UNKNOWN) {
116116
ret = xav_nif_raise(env, "invalid_profile");
117117
goto clean;
118118
}
@@ -302,10 +302,10 @@ static int get_profile(enum AVCodecID codec, const char *profile_name) {
302302
const AVProfile *profile = desc->profiles;
303303

304304
if (profile == NULL) {
305-
return FF_PROFILE_UNKNOWN;
305+
return AV_PROFILE_UNKNOWN;
306306
}
307307

308-
while (profile->profile != FF_PROFILE_UNKNOWN) {
308+
while (profile->profile != AV_PROFILE_UNKNOWN) {
309309
if (strcmp(profile->name, profile_name) == 0) {
310310
break;
311311
}
@@ -326,7 +326,7 @@ static ERL_NIF_TERM codec_get_profiles(ErlNifEnv *env, const AVCodec *codec) {
326326
return result;
327327
}
328328

329-
while (profile->profile != FF_PROFILE_UNKNOWN) {
329+
while (profile->profile != AV_PROFILE_UNKNOWN) {
330330
ERL_NIF_TERM profile_name = enif_make_string(env, profile->name, ERL_NIF_LATIN1);
331331
result = enif_make_list_cell(env, profile_name, result);
332332

@@ -382,4 +382,4 @@ static int load(ErlNifEnv *env, void **priv, ERL_NIF_TERM load_info) {
382382
return 0;
383383
}
384384

385-
ERL_NIF_INIT(Elixir.Xav.Encoder.NIF, xav_funcs, &load, NULL, NULL, NULL);
385+
ERL_NIF_INIT(Elixir.Xav.Encoder.NIF, xav_funcs, &load, NULL, NULL, NULL);

0 commit comments

Comments
 (0)