Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
5e5583ef
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5e5583ef
编写于
2月 13, 2015
作者:
G
Gilles Chanteperdrix
提交者:
Martin Storsjö
2月 21, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libavformat: add AC3 RTP depacketization (RFC 4184)
Signed-off-by:
N
Martin Storsjö
<
martin@martin.st
>
上级
4438d1c6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
163 addition
and
2 deletion
+163
-2
Changelog
Changelog
+1
-0
libavformat/Makefile
libavformat/Makefile
+1
-0
libavformat/rtpdec.c
libavformat/rtpdec.c
+1
-0
libavformat/rtpdec_ac3.c
libavformat/rtpdec_ac3.c
+157
-0
libavformat/rtpdec_formats.h
libavformat/rtpdec_formats.h
+1
-0
libavformat/version.h
libavformat/version.h
+2
-2
未找到文件。
Changelog
浏览文件 @
5e5583ef
...
...
@@ -16,6 +16,7 @@ version <next>:
- AAC ELD 480 decoding
- Intel QSV-accelerated H.264 decoding
- DSS SP decoder and DSS demuxer
- RTP depacketizer for AC3 payload format (RFC 4184)
version 11:
...
...
libavformat/Makefile
浏览文件 @
5e5583ef
...
...
@@ -28,6 +28,7 @@ OBJS-$(CONFIG_RIFFENC) += riffenc.o
OBJS-$(CONFIG_RTPDEC)
+=
rdt.o
\
rtp.o
\
rtpdec.o
\
rtpdec_ac3.o
\
rtpdec_amr.o
\
rtpdec_asf.o
\
rtpdec_g726.o
\
...
...
libavformat/rtpdec.c
浏览文件 @
5e5583ef
...
...
@@ -60,6 +60,7 @@ void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler)
void
ff_register_rtp_dynamic_payload_handlers
(
void
)
{
ff_register_dynamic_payload_handler
(
&
ff_ac3_dynamic_handler
);
ff_register_dynamic_payload_handler
(
&
ff_amr_nb_dynamic_handler
);
ff_register_dynamic_payload_handler
(
&
ff_amr_wb_dynamic_handler
);
ff_register_dynamic_payload_handler
(
&
ff_g726_16_dynamic_handler
);
...
...
libavformat/rtpdec_ac3.c
0 → 100644
浏览文件 @
5e5583ef
/*
* RTP parser for AC3 payload format (RFC 4184)
* Copyright (c) 2015 Gilles Chanteperdrix <gch@xenomai.org>
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "rtpdec_formats.h"
#define RTP_AC3_PAYLOAD_HEADER_SIZE 2
struct
PayloadContext
{
unsigned
nr_frames
;
unsigned
last_frame
;
uint32_t
timestamp
;
AVIOContext
*
fragment
;
};
static
av_cold
int
ac3_init
(
AVFormatContext
*
s
,
int
st_index
,
PayloadContext
*
data
)
{
if
(
st_index
<
0
)
return
0
;
s
->
streams
[
st_index
]
->
need_parsing
=
AVSTREAM_PARSE_FULL
;
return
0
;
}
static
PayloadContext
*
ac3_new_context
(
void
)
{
return
av_mallocz
(
sizeof
(
PayloadContext
));
}
static
void
free_fragment
(
PayloadContext
*
data
)
{
if
(
data
->
fragment
)
{
uint8_t
*
p
;
avio_close_dyn_buf
(
data
->
fragment
,
&
p
);
av_free
(
p
);
data
->
fragment
=
NULL
;
}
}
static
void
ac3_free_context
(
PayloadContext
*
data
)
{
free_fragment
(
data
);
av_free
(
data
);
}
static
int
ac3_handle_packet
(
AVFormatContext
*
ctx
,
PayloadContext
*
data
,
AVStream
*
st
,
AVPacket
*
pkt
,
uint32_t
*
timestamp
,
const
uint8_t
*
buf
,
int
len
,
uint16_t
seq
,
int
flags
)
{
unsigned
frame_type
;
unsigned
nr_frames
;
int
err
;
if
(
len
<
RTP_AC3_PAYLOAD_HEADER_SIZE
+
1
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid %d bytes packet
\n
"
,
len
);
return
AVERROR_INVALIDDATA
;
}
frame_type
=
buf
[
0
]
&
0x3
;
nr_frames
=
buf
[
1
];
buf
+=
RTP_AC3_PAYLOAD_HEADER_SIZE
;
len
-=
RTP_AC3_PAYLOAD_HEADER_SIZE
;
switch
(
frame_type
)
{
case
0
:
/* One or more complete frames */
if
(
!
nr_frames
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid AC3 packet data
\n
"
);
return
AVERROR_INVALIDDATA
;
}
if
(
av_new_packet
(
pkt
,
len
))
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Out of memory.
\n
"
);
return
AVERROR
(
ENOMEM
);
}
pkt
->
stream_index
=
st
->
index
;
memcpy
(
pkt
->
data
,
buf
,
len
);
return
0
;
case
1
:
case
2
:
/* First fragment */
free_fragment
(
data
);
data
->
last_frame
=
1
;
data
->
nr_frames
=
nr_frames
;
err
=
avio_open_dyn_buf
(
&
data
->
fragment
);
if
(
err
<
0
)
return
err
;
avio_write
(
data
->
fragment
,
buf
,
len
);
data
->
timestamp
=
*
timestamp
;
return
AVERROR
(
EAGAIN
);
case
3
:
/* Fragment other than first */
if
(
!
data
->
fragment
)
{
av_log
(
ctx
,
AV_LOG_WARNING
,
"Received packet without a start fragment; dropping.
\n
"
);
return
AVERROR
(
EAGAIN
);
}
if
(
nr_frames
!=
data
->
nr_frames
||
data
->
timestamp
!=
*
timestamp
)
{
free_fragment
(
data
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid packet received
\n
"
);
return
AVERROR_INVALIDDATA
;
}
avio_write
(
data
->
fragment
,
buf
,
len
);
data
->
last_frame
++
;
}
if
(
!
(
flags
&
RTP_FLAG_MARKER
))
return
AVERROR
(
EAGAIN
);
if
(
data
->
last_frame
!=
data
->
nr_frames
)
{
free_fragment
(
data
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Missed %d packets
\n
"
,
data
->
nr_frames
-
data
->
last_frame
);
return
AVERROR_INVALIDDATA
;
}
err
=
ff_rtp_finalize_packet
(
pkt
,
&
data
->
fragment
,
st
->
index
);
if
(
err
<
0
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Error occurred when getting fragment buffer.
\n
"
);
return
err
;
}
return
0
;
}
RTPDynamicProtocolHandler
ff_ac3_dynamic_handler
=
{
.
enc_name
=
"ac3"
,
.
codec_type
=
AVMEDIA_TYPE_AUDIO
,
.
codec_id
=
AV_CODEC_ID_AC3
,
.
init
=
ac3_init
,
.
alloc
=
ac3_new_context
,
.
free
=
ac3_free_context
,
.
parse_packet
=
ac3_handle_packet
,
};
libavformat/rtpdec_formats.h
浏览文件 @
5e5583ef
...
...
@@ -43,6 +43,7 @@ int ff_h264_handle_aggregated_packet(AVFormatContext *ctx, AVPacket *pkt,
int
start_skip
,
int
*
nal_counters
,
int
nal_mask
);
extern
RTPDynamicProtocolHandler
ff_ac3_dynamic_handler
;
extern
RTPDynamicProtocolHandler
ff_amr_nb_dynamic_handler
;
extern
RTPDynamicProtocolHandler
ff_amr_wb_dynamic_handler
;
extern
RTPDynamicProtocolHandler
ff_g726_16_dynamic_handler
;
...
...
libavformat/version.h
浏览文件 @
5e5583ef
...
...
@@ -30,8 +30,8 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 56
#define LIBAVFORMAT_VERSION_MINOR 1
2
#define LIBAVFORMAT_VERSION_MICRO
1
#define LIBAVFORMAT_VERSION_MINOR 1
3
#define LIBAVFORMAT_VERSION_MICRO
0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录