Skip to content

Commit 2878b3d

Browse files
committed
wip
1 parent df7c1eb commit 2878b3d

File tree

6 files changed

+116
-34
lines changed

6 files changed

+116
-34
lines changed

avcodec.cpp

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern AVCodec ff_vorbis_decoder;
3939

4040
void avcodec_init()
4141
{
42-
av_log_set_level(AV_LOG_INFO);
42+
av_log_set_level(AV_LOG_ERROR);
4343
}
4444

4545
struct avcodec_decoder_struct {
@@ -228,7 +228,6 @@ avcodec_decoder avcodec_decoder_create(const opencv_mat buf, const bool hevc_ena
228228
}
229229

230230
const AVCodec* codec = avcodec_find_decoder(codec_params->codec_id);
231-
232231
if (!codec) {
233232
avcodec_decoder_release(d);
234233
return NULL;
@@ -252,16 +251,6 @@ avcodec_decoder avcodec_decoder_create(const opencv_mat buf, const bool hevc_ena
252251
return NULL;
253252
}
254253

255-
// Configure AV1 decoder for software-only decoding
256-
if (codec->id == AV_CODEC_ID_AV1) {
257-
// Explicitly disable hardware acceleration to prevent format errors
258-
d->codec->hw_device_ctx = NULL;
259-
d->codec->hwaccel_context = NULL;
260-
d->codec->hwaccel = NULL;
261-
d->codec->get_format = NULL; // Use default software format selection
262-
d->codec->thread_count = 0; // Let FFmpeg choose optimal thread count
263-
}
264-
265254
res = avcodec_open2(d->codec, codec, NULL);
266255
if (res < 0) {
267256
avcodec_decoder_release(d);
@@ -348,11 +337,16 @@ int avcodec_decoder_get_orientation(const avcodec_decoder d)
348337
}
349338
else {
350339
uint8_t* displaymatrix = NULL;
351-
size_t side_data_size = 0;
352-
353-
// Get side data from stream
354-
AVStream* stream = d->container->streams[d->video_stream_index];
355-
displaymatrix = av_stream_get_side_data(stream, AV_PKT_DATA_DISPLAYMATRIX, &side_data_size);
340+
const AVPacketSideData* sd = NULL;
341+
342+
// access side data from codecpar instead of directly from the stream
343+
AVCodecParameters* codecpar = d->container->streams[d->video_stream_index]->codecpar;
344+
for (int i = 0; i < codecpar->nb_coded_side_data; i++) {
345+
if (codecpar->coded_side_data[i].type == AV_PKT_DATA_DISPLAYMATRIX) {
346+
sd = &codecpar->coded_side_data[i];
347+
break;
348+
}
349+
}
356350

357351
if (displaymatrix) {
358352
rotation = (360 - (int)(av_display_rotation_get((const int32_t*)displaymatrix))) % 360;
@@ -421,7 +415,7 @@ bool avcodec_decoder_has_subtitles(const avcodec_decoder d)
421415

422416
static int avcodec_decoder_copy_frame(const avcodec_decoder d, opencv_mat mat, AVFrame* frame)
423417
{
424-
if (!d || !d->codec || !mat || !frame) {
418+
if (!d || !d->codec || !d->codec->codec || !mat || !frame) {
425419
return -1;
426420
}
427421

@@ -430,11 +424,6 @@ static int avcodec_decoder_copy_frame(const avcodec_decoder d, opencv_mat mat, A
430424
return -1;
431425
}
432426

433-
// Extra safety check for AV1 decoder context
434-
if (!d->codec->codec) {
435-
return AVERROR(EINVAL);
436-
}
437-
438427
int res = avcodec_receive_frame(d->codec, frame);
439428
if (res >= 0) {
440429
// Calculate the step size based on the cv::Mat's width
@@ -527,18 +516,10 @@ static int avcodec_decoder_decode_packet(const avcodec_decoder d, opencv_mat mat
527516

528517
bool avcodec_decoder_decode(const avcodec_decoder d, opencv_mat mat)
529518
{
530-
if (!d) {
531-
return false;
532-
}
533-
if (!d->container) {
534-
return false;
535-
}
536-
if (!d->codec) {
537-
return false;
538-
}
539-
if (!mat) {
519+
if (!d || !d->container || !d->codec || !mat) {
540520
return false;
541521
}
522+
542523
AVPacket packet;
543524
bool done = false;
544525
bool success = false;

deps/build-deps-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ echo '\n--------------------'
387387
echo 'Building ffmpeg'
388388
echo '--------------------\n'
389389
mkdir -p $BASEDIR/ffmpeg
390-
tar -xjf $SRCDIR/ffmpeg-5.1.1.tar.bz2 -C $BASEDIR/ffmpeg --strip-components 1
390+
tar -xJf $SRCDIR/ffmpeg-7.0.2.orig.tar.xz -C $BASEDIR/ffmpeg --strip-components 1
391391
mkdir -p $BUILDDIR/ffmpeg
392392
cd $BUILDDIR/ffmpeg
393393
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"

third-party-licenses/dav1d.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright © 2018-2019, VideoLAN and dav1d authors
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

third-party-licenses/lcms.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Marti Maria Saguer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject
11+
to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

third-party-licenses/libaom.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2016, Alliance for Open Media. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions
5+
are met:
6+
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in
12+
the documentation and/or other materials provided with the
13+
distribution.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19+
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
POSSIBILITY OF SUCH DAMAGE.
27+

third-party-licenses/libyuv.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Copyright 2011 The LibYuv Project Authors. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in
12+
the documentation and/or other materials provided with the
13+
distribution.
14+
15+
* Neither the name of Google nor the names of its contributors may
16+
be used to endorse or promote products derived from this software
17+
without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)