Merge commit '9c09fbd8053292267cdc4b542913ceced43ea3a9'
* commit '9c09fbd8053292267cdc4b542913ceced43ea3a9': rtpdec: experimental VP9 depacketizer (draft 0) Conflicts: libavformat/rtpdec.c libavformat/rtpdec_vp9.c libavformat/version.h See: e4a6486c17dd90b338450ac7e151ffbf5370948a See: f966ac2b6e3f08c41f3c45ab5efff768db62ac5a See: 629a03a9128bd2e51286258e12183b1d06f509a7 Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
63ea3a86b7
@ -35,6 +35,7 @@ version <next>:
|
|||||||
- Fix stsd atom corruption in DNxHD QuickTimes
|
- Fix stsd atom corruption in DNxHD QuickTimes
|
||||||
- Canopus HQX decoder
|
- Canopus HQX decoder
|
||||||
- RTP depacketization of T.140 text (RFC 4103)
|
- RTP depacketization of T.140 text (RFC 4103)
|
||||||
|
- VP9 RTP payload format (draft 0) experimental depacketizer
|
||||||
|
|
||||||
|
|
||||||
version 2.5:
|
version 2.5:
|
||||||
|
@ -17,10 +17,9 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
* License along with FFmpeg; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libavcodec/bytestream.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
|
|
||||||
#include "avio_internal.h"
|
#include "avio_internal.h"
|
||||||
#include "rtpdec_formats.h"
|
#include "rtpdec_formats.h"
|
||||||
@ -35,15 +34,9 @@ struct PayloadContext {
|
|||||||
static av_cold int vp9_init(AVFormatContext *ctx, int st_index,
|
static av_cold int vp9_init(AVFormatContext *ctx, int st_index,
|
||||||
PayloadContext *data)
|
PayloadContext *data)
|
||||||
{
|
{
|
||||||
av_dlog(ctx, "vp9_init() for stream %d\n", st_index);
|
|
||||||
av_log(ctx, AV_LOG_WARNING,
|
av_log(ctx, AV_LOG_WARNING,
|
||||||
"RTP/VP9 support is still experimental\n");
|
"RTP/VP9 support is still experimental\n");
|
||||||
|
|
||||||
if (st_index < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ctx->streams[st_index]->need_parsing = AVSTREAM_PARSE_FULL;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,12 +50,12 @@ static int vp9_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_vp9_ctx,
|
|||||||
av_unused int layer_temporal = -1, layer_spatial = -1, layer_quality = -1;
|
av_unused int layer_temporal = -1, layer_spatial = -1, layer_quality = -1;
|
||||||
int ref_fields = 0, has_ref_field_ext_pic_id = 0;
|
int ref_fields = 0, has_ref_field_ext_pic_id = 0;
|
||||||
int first_fragment, last_fragment;
|
int first_fragment, last_fragment;
|
||||||
|
int rtp_m;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
/* drop data of previous packets in case of non-continuous (lossy) packet stream */
|
/* drop data of previous packets in case of non-continuous (lossy) packet stream */
|
||||||
if (rtp_vp9_ctx->buf && rtp_vp9_ctx->timestamp != *timestamp) {
|
if (rtp_vp9_ctx->buf && rtp_vp9_ctx->timestamp != *timestamp)
|
||||||
ffio_free_dyn_buf(&rtp_vp9_ctx->buf);
|
ffio_free_dyn_buf(&rtp_vp9_ctx->buf);
|
||||||
}
|
|
||||||
|
|
||||||
/* sanity check for size of input packet: 1 byte payload at least */
|
/* sanity check for size of input packet: 1 byte payload at least */
|
||||||
if (len < RTP_VP9_DESC_REQUIRED_SIZE + 1) {
|
if (len < RTP_VP9_DESC_REQUIRED_SIZE + 1) {
|
||||||
@ -71,32 +64,34 @@ static int vp9_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_vp9_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
decode the required VP9 payload descriptor according to section 4.2 of the spec.:
|
* decode the required VP9 payload descriptor according to section 4.2 of the spec.:
|
||||||
|
*
|
||||||
0 1 2 3 4 5 6 7
|
* 0 1 2 3 4 5 6 7
|
||||||
+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+
|
||||||
|I|L|F|B|E|V|U|-| (REQUIRED)
|
* |I|L|F|B|E|V|U|-| (REQUIRED)
|
||||||
+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
I: PictureID present
|
* I: PictureID present
|
||||||
L: Layer indices present
|
* L: Layer indices present
|
||||||
F: Reference indices present
|
* F: Reference indices present
|
||||||
B: Start of VP9 frame
|
* B: Start of VP9 frame
|
||||||
E: End of picture
|
* E: End of picture
|
||||||
V: Scalability Structure (SS) present
|
* V: Scalability Structure (SS) present
|
||||||
U: Scalability Structure Update (SU) present
|
* U: Scalability Structure Update (SU) present
|
||||||
*/
|
*/
|
||||||
has_pic_id = buf[0] & 0x80;
|
has_pic_id = !!(buf[0] & 0x80);
|
||||||
has_layer_idc = buf[0] & 0x40;
|
has_layer_idc = !!(buf[0] & 0x40);
|
||||||
has_ref_idc = buf[0] & 0x20;
|
has_ref_idc = !!(buf[0] & 0x20);
|
||||||
first_fragment = buf[0] & 0x10;
|
first_fragment = !!(buf[0] & 0x10);
|
||||||
last_fragment = buf[0] & 0x08;
|
last_fragment = !!(buf[0] & 0x08);
|
||||||
has_ss_data = buf[0] & 0x04;
|
has_ss_data = !!(buf[0] & 0x04);
|
||||||
has_su_data = buf[0] & 0x02;
|
has_su_data = !!(buf[0] & 0x02);
|
||||||
|
|
||||||
|
rtp_m = !!(flags & RTP_FLAG_MARKER);
|
||||||
|
|
||||||
/* sanity check for markers: B should always be equal to the RTP M marker */
|
/* sanity check for markers: B should always be equal to the RTP M marker */
|
||||||
if (last_fragment >> 2 != flags & RTP_FLAG_MARKER) {
|
if (last_fragment != rtp_m) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Invalid combination of B and M marker\n");
|
av_log(ctx, AV_LOG_ERROR, "Invalid combination of B and M marker (%d != %d)\n", last_fragment, rtp_m);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,17 +100,17 @@ static int vp9_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_vp9_ctx,
|
|||||||
len -= RTP_VP9_DESC_REQUIRED_SIZE;
|
len -= RTP_VP9_DESC_REQUIRED_SIZE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
decode the 1-byte/2-byte picture ID:
|
* decode the 1-byte/2-byte picture ID:
|
||||||
|
*
|
||||||
0 1 2 3 4 5 6 7
|
* 0 1 2 3 4 5 6 7
|
||||||
+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+
|
||||||
I: |M|PICTURE ID | (RECOMMENDED)
|
* I: |M|PICTURE ID | (RECOMMENDED)
|
||||||
+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+
|
||||||
M: | EXTENDED PID | (RECOMMENDED)
|
* M: | EXTENDED PID | (RECOMMENDED)
|
||||||
+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
M: The most significant bit of the first octet is an extension flag.
|
* M: The most significant bit of the first octet is an extension flag.
|
||||||
PictureID: 8 or 16 bits including the M bit.
|
* PictureID: 8 or 16 bits including the M bit.
|
||||||
*/
|
*/
|
||||||
if (has_pic_id) {
|
if (has_pic_id) {
|
||||||
if (len < 1) {
|
if (len < 1) {
|
||||||
@ -140,20 +135,20 @@ static int vp9_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_vp9_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
decode layer indices
|
* decode layer indices
|
||||||
|
*
|
||||||
0 1 2 3 4 5 6 7
|
* 0 1 2 3 4 5 6 7
|
||||||
+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+
|
||||||
L: | T | S | Q | R | (CONDITIONALLY RECOMMENDED)
|
* L: | T | S | Q | R | (CONDITIONALLY RECOMMENDED)
|
||||||
+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
T, S and Q are 2-bit indices for temporal, spatial, and quality layers.
|
* T, S and Q are 2-bit indices for temporal, spatial, and quality layers.
|
||||||
If "F" is set in the initial octet, R is 2 bits representing the number
|
* If "F" is set in the initial octet, R is 2 bits representing the number
|
||||||
of reference fields this frame refers to.
|
* of reference fields this frame refers to.
|
||||||
*/
|
*/
|
||||||
if (has_layer_idc) {
|
if (has_layer_idc) {
|
||||||
if (len < 1) {
|
if (len < 1) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet");
|
av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
layer_temporal = buf[0] & 0xC0;
|
layer_temporal = buf[0] & 0xC0;
|
||||||
@ -169,18 +164,18 @@ static int vp9_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_vp9_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
decode the reference fields
|
* decode the reference fields
|
||||||
|
*
|
||||||
0 1 2 3 4 5 6 7
|
* 0 1 2 3 4 5 6 7
|
||||||
+-+-+-+-+-+-+-+-+ -\
|
* +-+-+-+-+-+-+-+-+ -\
|
||||||
F: | PID |X| RS| RQ| (OPTIONAL) .
|
* F: | PID |X| RS| RQ| (OPTIONAL) .
|
||||||
+-+-+-+-+-+-+-+-+ . - R times
|
* +-+-+-+-+-+-+-+-+ . - R times
|
||||||
X: | EXTENDED PID | (OPTIONAL) .
|
* X: | EXTENDED PID | (OPTIONAL) .
|
||||||
+-+-+-+-+-+-+-+-+ -/
|
* +-+-+-+-+-+-+-+-+ -/
|
||||||
|
*
|
||||||
PID: The relative Picture ID referred to by this frame.
|
* PID: The relative Picture ID referred to by this frame.
|
||||||
RS and RQ: The spatial and quality layer IDs.
|
* RS and RQ: The spatial and quality layer IDs.
|
||||||
X: 1 if this layer index has an extended relative Picture ID.
|
* X: 1 if this layer index has an extended relative Picture ID.
|
||||||
*/
|
*/
|
||||||
if (has_ref_idc) {
|
if (has_ref_idc) {
|
||||||
while (ref_fields) {
|
while (ref_fields) {
|
||||||
@ -214,42 +209,42 @@ static int vp9_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_vp9_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
decode the scalability structure (SS)
|
* decode the scalability structure (SS)
|
||||||
|
*
|
||||||
0 1 2 3 4 5 6 7
|
* 0 1 2 3 4 5 6 7
|
||||||
+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+
|
||||||
V: | PATTERN LENGTH|
|
* V: | PATTERN LENGTH|
|
||||||
+-+-+-+-+-+-+-+-+ -\
|
* +-+-+-+-+-+-+-+-+ -\
|
||||||
| T | S | Q | R | (OPTIONAL) .
|
* | T | S | Q | R | (OPTIONAL) .
|
||||||
+-+-+-+-+-+-+-+-+ -\ .
|
* +-+-+-+-+-+-+-+-+ -\ .
|
||||||
| PID |X| RS| RQ| (OPTIONAL) . . - PAT. LEN. times
|
* | PID |X| RS| RQ| (OPTIONAL) . . - PAT. LEN. times
|
||||||
+-+-+-+-+-+-+-+-+ . - R times .
|
* +-+-+-+-+-+-+-+-+ . - R times .
|
||||||
X: | EXTENDED PID | (OPTIONAL) . .
|
* X: | EXTENDED PID | (OPTIONAL) . .
|
||||||
+-+-+-+-+-+-+-+-+ -/ -/
|
* +-+-+-+-+-+-+-+-+ -/ -/
|
||||||
|
*
|
||||||
PID: The relative Picture ID referred to by this frame.
|
* PID: The relative Picture ID referred to by this frame.
|
||||||
RS and RQ: The spatial and quality layer IDs.
|
* RS and RQ: The spatial and quality layer IDs.
|
||||||
X: 1 if this layer index has an extended relative Picture ID.
|
* X: 1 if this layer index has an extended relative Picture ID.
|
||||||
*/
|
*/
|
||||||
if (has_ss_data) {
|
if (has_ss_data) {
|
||||||
avpriv_report_missing_feature(ctx, "VP9 scalability structure data\n");
|
avpriv_report_missing_feature(ctx, "VP9 scalability structure data");
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR(ENOSYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
decode the scalability update structure (SU)
|
* decode the scalability update structure (SU)
|
||||||
|
*
|
||||||
spec. is tbd
|
* spec. is tbd
|
||||||
*/
|
*/
|
||||||
if (has_su_data) {
|
if (has_su_data) {
|
||||||
avpriv_report_missing_feature(ctx, "VP9 scalability update structure data\n");
|
avpriv_report_missing_feature(ctx, "VP9 scalability update structure data");
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR(ENOSYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
decode the VP9 payload header
|
* decode the VP9 payload header
|
||||||
|
*
|
||||||
spec. is tbd
|
* spec. is tbd
|
||||||
*/
|
*/
|
||||||
//XXX: implement when specified
|
//XXX: implement when specified
|
||||||
|
|
||||||
@ -293,7 +288,7 @@ RTPDynamicProtocolHandler ff_vp9_dynamic_handler = {
|
|||||||
.enc_name = "VP9",
|
.enc_name = "VP9",
|
||||||
.codec_type = AVMEDIA_TYPE_VIDEO,
|
.codec_type = AVMEDIA_TYPE_VIDEO,
|
||||||
.codec_id = AV_CODEC_ID_VP9,
|
.codec_id = AV_CODEC_ID_VP9,
|
||||||
.init = vp9_init,
|
|
||||||
.priv_data_size = sizeof(PayloadContext),
|
.priv_data_size = sizeof(PayloadContext),
|
||||||
|
.init = vp9_init,
|
||||||
.parse_packet = vp9_handle_packet
|
.parse_packet = vp9_handle_packet
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_MAJOR 56
|
#define LIBAVFORMAT_VERSION_MAJOR 56
|
||||||
#define LIBAVFORMAT_VERSION_MINOR 25
|
#define LIBAVFORMAT_VERSION_MINOR 25
|
||||||
#define LIBAVFORMAT_VERSION_MICRO 100
|
#define LIBAVFORMAT_VERSION_MICRO 101
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||||
LIBAVFORMAT_VERSION_MINOR, \
|
LIBAVFORMAT_VERSION_MINOR, \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user