Skip to content

Commit

Permalink
Remove use of deprecated av_packet_side_data_get
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Feb 23, 2024
1 parent 828f254 commit ce9b97f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
1.2.0 (unreleased)
=====
* Removed unused `Av.write_audio_frame`/`Av.write_video_frame`.
* Remove use of deprecated `av_packet_side_data_get`
* Added support to get all streams from output container
* Removed unreliable `Av.was_keyframe`
* Added `on_keyframe` to `Av.write_frame`.
Expand Down
23 changes: 14 additions & 9 deletions av/av_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2495,19 +2495,24 @@ CAMLprim value ocaml_av_stream_bitrate(value _stream) {
if (!stream)
CAMLreturn(Val_none);

AVCPBProperties *props = (AVCPBProperties *)av_stream_get_side_data(
stream, AV_PKT_DATA_CPB_PROPERTIES, NULL);
if (stream->codecpar->bit_rate) {
ans = caml_alloc_tuple(1);
Store_field(ans, 0, Val_int(stream->codecpar->bit_rate));
CAMLreturn(ans);
}

if (!stream->codecpar->bit_rate && !props)
const AVPacketSideData *side_data = av_packet_side_data_get(
stream->codecpar->coded_side_data, stream->codecpar->nb_coded_side_data,
AV_PKT_DATA_CPB_PROPERTIES);
if (!side_data)
CAMLreturn(Val_none);

ans = caml_alloc_tuple(1);
AVCPBProperties *props = (AVCPBProperties *)side_data->data;

if (stream->codecpar->bit_rate) {
Store_field(ans, 0, Val_int(stream->codecpar->bit_rate));
} else if (props) {
Store_field(ans, 0, Val_int(props->max_bitrate));
}
if (!props)
CAMLreturn(Val_none);

ans = caml_alloc_tuple(1);
Store_field(ans, 0, Val_int(props->max_bitrate));
CAMLreturn(ans);
}
3 changes: 2 additions & 1 deletion av/config/discover.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module C = Configurator.V1

let packages = [("avutil", "55.78.100"); ("avformat", "57.83.100")]
let packages =
[("avutil", "55.78.100"); ("avformat", "57.83.100"); ("avcodec", "60.29.100")]

let () =
C.main ~name:"ffmpeg-av-pkg-config" (fun c ->
Expand Down

0 comments on commit ce9b97f

Please sign in to comment.