Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
f381f0df
Commit
f381f0df
authored
1 year ago
by
Adrien Béraud
Committed by
Adrien Béraud
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
media decoder: support floating point
Change-Id: Ifea0a1ebd9cc36214b0532c01119333cd269f1a0
parent
faaf9460
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/media/libav_utils.cpp
+28
-0
28 additions, 0 deletions
src/media/libav_utils.cpp
src/media/libav_utils.h
+6
-0
6 additions, 0 deletions
src/media/libav_utils.h
src/media/media_decoder.cpp
+10
-6
10 additions, 6 deletions
src/media/media_decoder.cpp
with
44 additions
and
6 deletions
src/media/libav_utils.cpp
+
28
−
0
View file @
f381f0df
...
...
@@ -56,6 +56,34 @@ av_frame_new_side_data_from_buf(AVFrame* frame, enum AVFrameSideDataType type, A
namespace
jami
{
namespace
libav_utils
{
AVSampleFormat
choose_sample_fmt
(
const
AVCodec
*
codec
,
const
AVSampleFormat
*
preferred_formats
,
int
preferred_formats_count
)
{
for
(
int
i
=
0
;
i
<
preferred_formats_count
;
++
i
)
{
for
(
auto
it
=
codec
->
sample_fmts
;
*
it
!=
-
1
;
++
it
)
{
if
(
*
it
==
preferred_formats
[
i
])
return
preferred_formats
[
i
];
}
}
return
AV_SAMPLE_FMT_NONE
;
}
AVSampleFormat
choose_sample_fmt_default
(
const
AVCodec
*
codec
,
AVSampleFormat
defaultFormat
)
{
// List of supported formats, current default first
const
AVSampleFormat
preferred_formats
[]
=
{
defaultFormat
,
AV_SAMPLE_FMT_FLTP
,
AV_SAMPLE_FMT_FLT
,
AV_SAMPLE_FMT_S16P
,
AV_SAMPLE_FMT_S16
,
AV_SAMPLE_FMT_DBLP
,
AV_SAMPLE_FMT_DBL
,
AV_SAMPLE_FMT_S32P
,
AV_SAMPLE_FMT_S32
};
return
choose_sample_fmt
(
codec
,
preferred_formats
,
sizeof
(
preferred_formats
)
/
sizeof
(
preferred_formats
[
0
]));
}
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
// protect libav/ffmpeg access
static
int
...
...
This diff is collapsed.
Click to expand it.
src/media/libav_utils.h
+
6
−
0
View file @
f381f0df
...
...
@@ -21,6 +21,8 @@
#pragma once
#include
<libavutil/samplefmt.h>
#include
<vector>
#include
<map>
#include
<string>
...
...
@@ -31,6 +33,7 @@ struct AVDictionary;
struct
AVFrame
;
struct
AVPixFmtDescriptor
;
struct
AVBufferRef
;
struct
AVCodec
;
void
av_buffer_unref
(
AVBufferRef
**
buf
);
}
...
...
@@ -42,6 +45,9 @@ void av_init();
const
char
*
const
DEFAULT_H264_PROFILE_LEVEL_ID
=
"profile-level-id=428029"
;
const
char
*
const
MAX_H264_PROFILE_LEVEL_ID
=
"profile-level-id=640034"
;
enum
AVSampleFormat
choose_sample_fmt
(
const
AVCodec
*
codec
,
const
enum
AVSampleFormat
*
preferred_formats
,
int
preferred_formats_count
);
enum
AVSampleFormat
choose_sample_fmt_default
(
const
AVCodec
*
codec
,
enum
AVSampleFormat
defaultFormat
);
bool
is_yuv_planar
(
const
AVPixFmtDescriptor
&
desc
);
std
::
string
getError
(
int
err
);
...
...
This diff is collapsed.
Click to expand it.
src/media/media_decoder.cpp
+
10
−
6
View file @
f381f0df
...
...
@@ -27,6 +27,7 @@
#include
"media_io_handle.h"
#include
"audio/ringbuffer.h"
#include
"audio/resampler.h"
#include
"audio/ringbufferpool.h"
#include
"decoder_finder.h"
#include
"manager.h"
...
...
@@ -147,10 +148,10 @@ MediaDemuxer::openInput(const DeviceParams& params)
std
::
string
input
=
params
.
input
;
#endif
JAMI_
DB
G
(
"Trying to open
device %s
with format
%s
, pixel format
%s
, size
%dx%d
, rate
%lf
"
,
input
.
c_str
()
,
params
.
format
.
c_str
()
,
params
.
pixel_format
.
c_str
()
,
JAMI_
LO
G
(
"Trying to open
input {}
with format
{}
, pixel format
{}
, size
{}x{}
, rate
{}
"
,
input
,
params
.
format
,
params
.
pixel_format
,
params
.
width
,
params
.
height
,
params
.
framerate
.
real
());
...
...
@@ -574,13 +575,13 @@ MediaDecoder::prepareDecoderContext()
{
inputDecoder_
=
findDecoder
(
avStream_
->
codecpar
->
codec_id
);
if
(
!
inputDecoder_
)
{
JAMI_ERR
()
<<
"Unsupported codec"
;
JAMI_ERR
OR
(
"Unsupported codec"
)
;
return
-
1
;
}
decoderCtx_
=
avcodec_alloc_context3
(
inputDecoder_
);
if
(
!
decoderCtx_
)
{
JAMI_ERR
()
<<
"Failed to create decoder context"
;
JAMI_ERR
OR
(
"Failed to create decoder context"
)
;
return
-
1
;
}
avcodec_parameters_to_context
(
decoderCtx_
,
avStream_
->
codecpar
);
...
...
@@ -597,6 +598,9 @@ MediaDecoder::prepareDecoderContext()
if
(
decoderCtx_
->
codec_id
==
AV_CODEC_ID_OPUS
)
{
av_opt_set_int
(
decoderCtx_
,
"decode_fec"
,
fecEnabled_
?
1
:
0
,
AV_OPT_SEARCH_CHILDREN
);
}
auto
format
=
libav_utils
::
choose_sample_fmt_default
(
inputDecoder_
,
Manager
::
instance
().
getRingBufferPool
().
getInternalAudioFormat
().
sampleFormat
);
decoderCtx_
->
sample_fmt
=
format
;
decoderCtx_
->
request_sample_fmt
=
format
;
}
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment