Skip to content

Replace av_init_packet in FFmpeg 3.2+ - #784

Merged
ferdnyc merged 3 commits into
OpenShot:developfrom
ferdnyc:replace-initpacket
Mar 17, 2022
Merged

Replace av_init_packet in FFmpeg 3.2+#784
ferdnyc merged 3 commits into
OpenShot:developfrom
ferdnyc:replace-initpacket

Conversation

@ferdnyc

@ferdnycferdnyc commented Dec 10, 2021

Copy link
Copy Markdown
Contributor

av_init_packet is now deprecated in the newest FFmpeg, mostly because we shouldn't be using it anyway. In all FFmpeg versions since 3.0, we've had av_packet_alloc() instead, which is the preferred method of initializing a packet pointer.

Note that I said packet pointer, not a packet — making this change required changing all pkt instances from AVPacket to AVPacket*, and adding the necessary pointer dereferences to all uses. (Or, as often as not, changing a library call to stop taking the address of the locally-allocated struct, and instead just pass it the pointer.)

FFmpeg 2.8 — which we still depressingly support (in theory) — doesn't have an av_packet_alloc(), so its use is sequestered behind an #if IS_FFMPEG_3_2 check. If that fails the old av_init_packet() method is used instead, but it now initializes an AVPacket* instead. Hopefully that will work; if not, we don't have any CI that checks FFmpeg < 3.4 anymore, so I guess we'll find out if an Ubuntu 16.04 user complains. Of course, any remaining Ubuntu 16.04 users are running an unsupported system that's past its End-of-Life date, so I'm not really worried.

@ferdnyc

Copy link
Copy Markdown
ContributorAuthor

FFmpeg 2.8 — which we still depressingly support (in theory) — doesn't have an av_packet_alloc(), so its use is sequestered behind an #if IS_FFMPEG_3_2 check. If that fails the old av_init_packet() method is used instead, but it now initializes an AVPacket* instead. Hopefully that will work; if not, we don't have any CI that checks FFmpeg < 3.4 anymore, so I guess we'll find out if an Ubuntu 16.04 user complains. Of course, any remaining Ubuntu 16.04 users are running an unsupported system that's past its End-of-Life date, so I'm not really worried.

(This is my passive-aggressive way of saying, "We REALLY need to get all the crap FFmpeg 2.x code out of the library".) It's a whole lot of ugly code that may or may not still work — we have no idea, we haven't tested it in years.

FFmpeg 3.0 ushered in the era of the packet-centric pipeline, which radically changed the flow of code written with the library. Changes since then have been relatively minor, mostly deprecating or swapping around individual function calls in ways that don't change the program flow. But trying to keep FFmpeg 2.x and 3.x+ code together in the same codebase means loooong stretches of #ifdef'd code that do completely different things, while trying to pretend they're the same.

@codecov

codecovBot commented Dec 10, 2021

Copy link
Copy Markdown

Codecov Report

Merging #784 (530afb6) into develop (aee7621) will decrease coverage by 0.00%.
The diff coverage is 75.80%.

@@ Coverage Diff @@## develop #784 +/- ##
===========================================
- Coverage 48.38% 48.38% -0.01% 
===========================================
Files 185 185 Lines 17846 17848 +2 ===========================================
Hits 8635 8635 - Misses 9211 9213 +2 
Impacted FilesCoverage Δ
src/FFmpegWriter.cpp59.09% <75.80%> (-0.09%)⬇️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@github-actionsgithub-actionsBot added the conflicts A PR with unresolved merge conflicts label Mar 17, 2022
@github-actions

Copy link
Copy Markdown

Merge conflicts have been detected on this PR, please resolve.

@ferdnyc
ferdnyc merged commit 08b4975 into OpenShot:developMar 17, 2022
@ferdnyc
ferdnyc deleted the replace-initpacket branch March 17, 2022 03:58
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflictsA PR with unresolved merge conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@ferdnyc