Commit 78ac7ee9 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '5d471b73'

* commit '5d471b73':
  rtpdec: K&R formatting and spelling cosmetics
  cosmetics: Fix dropable --> droppable typo

Conflicts:
	libavcodec/h264.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 5c75708c 5d471b73
...@@ -89,8 +89,8 @@ int ff_flv_decode_picture_header(MpegEncContext *s) ...@@ -89,8 +89,8 @@ int ff_flv_decode_picture_header(MpegEncContext *s)
s->height = height; s->height = height;
s->pict_type = AV_PICTURE_TYPE_I + get_bits(&s->gb, 2); s->pict_type = AV_PICTURE_TYPE_I + get_bits(&s->gb, 2);
s->dropable= s->pict_type > AV_PICTURE_TYPE_P; s->droppable = s->pict_type > AV_PICTURE_TYPE_P;
if (s->dropable) if (s->droppable)
s->pict_type = AV_PICTURE_TYPE_P; s->pict_type = AV_PICTURE_TYPE_P;
skip_bits1(&s->gb); /* deblocking flag */ skip_bits1(&s->gb); /* deblocking flag */
...@@ -109,7 +109,8 @@ int ff_flv_decode_picture_header(MpegEncContext *s) ...@@ -109,7 +109,8 @@ int ff_flv_decode_picture_header(MpegEncContext *s)
if(s->avctx->debug & FF_DEBUG_PICT_INFO){ if(s->avctx->debug & FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n", av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
s->dropable ? 'D' : av_get_picture_type_char(s->pict_type), s->h263_flv-1, s->qscale, s->picture_number); s->droppable ? 'D' : av_get_picture_type_char(s->pict_type),
s->h263_flv - 1, s->qscale, s->picture_number);
} }
s->y_dc_scale_table= s->y_dc_scale_table=
......
...@@ -628,7 +628,9 @@ retry: ...@@ -628,7 +628,9 @@ retry:
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
/* skip B-frames if we don't have reference frames */ /* skip B-frames if we don't have reference frames */
if(s->last_picture_ptr==NULL && (s->pict_type==AV_PICTURE_TYPE_B || s->dropable)) return get_consumed_bytes(s, buf_size); if (s->last_picture_ptr == NULL &&
(s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
return get_consumed_bytes(s, buf_size);
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B) if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
|| (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|| avctx->skip_frame >= AVDISCARD_ALL) || avctx->skip_frame >= AVDISCARD_ALL)
......
...@@ -1275,7 +1275,7 @@ static int decode_update_thread_context(AVCodecContext *dst, ...@@ -1275,7 +1275,7 @@ static int decode_update_thread_context(AVCodecContext *dst,
if (!s->current_picture_ptr) if (!s->current_picture_ptr)
return 0; return 0;
if (!s->dropable) { if (!s->droppable) {
err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
h->prev_poc_msb = h->poc_msb; h->prev_poc_msb = h->poc_msb;
h->prev_poc_lsb = h->poc_lsb; h->prev_poc_lsb = h->poc_lsb;
...@@ -2252,7 +2252,7 @@ static int field_end(H264Context *h, int in_setup) ...@@ -2252,7 +2252,7 @@ static int field_end(H264Context *h, int in_setup)
int err = 0; int err = 0;
s->mb_y = 0; s->mb_y = 0;
if (!in_setup && !s->dropable) if (!in_setup && !s->droppable)
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX,
s->picture_structure == PICT_BOTTOM_FIELD); s->picture_structure == PICT_BOTTOM_FIELD);
...@@ -2261,7 +2261,7 @@ static int field_end(H264Context *h, int in_setup) ...@@ -2261,7 +2261,7 @@ static int field_end(H264Context *h, int in_setup)
ff_vdpau_h264_set_reference_frames(s); ff_vdpau_h264_set_reference_frames(s);
if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) { if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {
if (!s->dropable) { if (!s->droppable) {
err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
h->prev_poc_msb = h->poc_msb; h->prev_poc_msb = h->poc_msb;
h->prev_poc_lsb = h->poc_lsb; h->prev_poc_lsb = h->poc_lsb;
...@@ -2376,7 +2376,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -2376,7 +2376,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
int num_ref_idx_active_override_flag; int num_ref_idx_active_override_flag;
unsigned int slice_type, tmp, i, j; unsigned int slice_type, tmp, i, j;
int default_ref_list_done = 0; int default_ref_list_done = 0;
int last_pic_structure, last_pic_dropable; int last_pic_structure, last_pic_droppable;
int must_reinit; int must_reinit;
/* FIXME: 2tap qpel isn't implemented for high bit depth. */ /* FIXME: 2tap qpel isn't implemented for high bit depth. */
...@@ -2398,7 +2398,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -2398,7 +2398,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
h0->current_slice = 0; h0->current_slice = 0;
if (!s0->first_field) { if (!s0->first_field) {
if (s->current_picture_ptr && !s->dropable && if (s->current_picture_ptr && !s->droppable &&
s->current_picture_ptr->owner2 == s) { s->current_picture_ptr->owner2 == s) {
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX,
s->picture_structure == PICT_BOTTOM_FIELD); s->picture_structure == PICT_BOTTOM_FIELD);
...@@ -2684,8 +2684,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -2684,8 +2684,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
h->mb_mbaff = 0; h->mb_mbaff = 0;
h->mb_aff_frame = 0; h->mb_aff_frame = 0;
last_pic_structure = s0->picture_structure; last_pic_structure = s0->picture_structure;
last_pic_dropable = s0->dropable; last_pic_droppable = s0->droppable;
s->dropable = h->nal_ref_idc == 0; s->droppable = h->nal_ref_idc == 0;
if (h->sps.frame_mbs_only_flag) { if (h->sps.frame_mbs_only_flag) {
s->picture_structure = PICT_FRAME; s->picture_structure = PICT_FRAME;
} else { } else {
...@@ -2704,12 +2704,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -2704,12 +2704,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
if (h0->current_slice != 0) { if (h0->current_slice != 0) {
if (last_pic_structure != s->picture_structure || if (last_pic_structure != s->picture_structure ||
last_pic_dropable != s->dropable) { last_pic_droppable != s->droppable) {
av_log(h->s.avctx, AV_LOG_ERROR, av_log(h->s.avctx, AV_LOG_ERROR,
"Changing field mode (%d -> %d) between slices is not allowed\n", "Changing field mode (%d -> %d) between slices is not allowed\n",
last_pic_structure, s->picture_structure); last_pic_structure, s->picture_structure);
s->picture_structure = last_pic_structure; s->picture_structure = last_pic_structure;
s->dropable = last_pic_dropable; s->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} else if (!s0->current_picture_ptr) { } else if (!s0->current_picture_ptr) {
av_log(s->avctx, AV_LOG_ERROR, av_log(s->avctx, AV_LOG_ERROR,
...@@ -2747,7 +2747,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -2747,7 +2747,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
assert(s0->current_picture_ptr->f.reference != DELAYED_PIC_REF); assert(s0->current_picture_ptr->f.reference != DELAYED_PIC_REF);
/* Mark old field/frame as completed */ /* Mark old field/frame as completed */
if (!last_pic_dropable && s0->current_picture_ptr->owner2 == s0) { if (!last_pic_droppable && s0->current_picture_ptr->owner2 == s0) {
ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX, ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
last_pic_structure == PICT_BOTTOM_FIELD); last_pic_structure == PICT_BOTTOM_FIELD);
} }
...@@ -2756,7 +2756,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -2756,7 +2756,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
if (!FIELD_PICTURE || s->picture_structure == last_pic_structure) { if (!FIELD_PICTURE || s->picture_structure == last_pic_structure) {
/* Previous field is unmatched. Don't display it, but let it /* Previous field is unmatched. Don't display it, but let it
* remain for reference if marked as such. */ * remain for reference if marked as such. */
if (!last_pic_dropable && last_pic_structure != PICT_FRAME) { if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX, ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
last_pic_structure == PICT_TOP_FIELD); last_pic_structure == PICT_TOP_FIELD);
} }
...@@ -2766,7 +2766,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -2766,7 +2766,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
* different frame_nums. Consider this field first in * different frame_nums. Consider this field first in
* pair. Throw away previous field except for reference * pair. Throw away previous field except for reference
* purposes. */ * purposes. */
if (!last_pic_dropable && last_pic_structure != PICT_FRAME) { if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX, ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
last_pic_structure == PICT_TOP_FIELD); last_pic_structure == PICT_TOP_FIELD);
} }
...@@ -2780,14 +2780,14 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -2780,14 +2780,14 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
"Invalid field mode combination %d/%d\n", "Invalid field mode combination %d/%d\n",
last_pic_structure, s->picture_structure); last_pic_structure, s->picture_structure);
s->picture_structure = last_pic_structure; s->picture_structure = last_pic_structure;
s->dropable = last_pic_dropable; s->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} else if (last_pic_dropable != s->dropable) { } else if (last_pic_droppable != s->droppable) {
av_log(s->avctx, AV_LOG_ERROR, av_log(s->avctx, AV_LOG_ERROR,
"Cannot combine reference and non-reference fields in the same frame\n"); "Cannot combine reference and non-reference fields in the same frame\n");
av_log_ask_for_sample(s->avctx, NULL); av_log_ask_for_sample(s->avctx, NULL);
s->picture_structure = last_pic_structure; s->picture_structure = last_pic_structure;
s->dropable = last_pic_dropable; s->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
...@@ -3531,7 +3531,7 @@ static void decode_finish_row(H264Context *h) ...@@ -3531,7 +3531,7 @@ static void decode_finish_row(H264Context *h)
ff_draw_horiz_band(s, top, height); ff_draw_horiz_band(s, top, height);
if (s->dropable) if (s->droppable)
return; return;
ff_thread_report_progress(&s->current_picture_ptr->f, top + height - 1, ff_thread_report_progress(&s->current_picture_ptr->f, top + height - 1,
...@@ -3737,7 +3737,7 @@ static int execute_decode_slices(H264Context *h, int context_count) ...@@ -3737,7 +3737,7 @@ static int execute_decode_slices(H264Context *h, int context_count)
hx = h->thread_context[context_count - 1]; hx = h->thread_context[context_count - 1];
s->mb_x = hx->s.mb_x; s->mb_x = hx->s.mb_x;
s->mb_y = hx->s.mb_y; s->mb_y = hx->s.mb_y;
s->dropable = hx->s.dropable; s->droppable = hx->s.droppable;
s->picture_structure = hx->s.picture_structure; s->picture_structure = hx->s.picture_structure;
for (i = 1; i < context_count; i++) for (i = 1; i < context_count; i++)
h->s.error_count += h->thread_context[i]->s.error_count; h->s.error_count += h->thread_context[i]->s.error_count;
...@@ -4082,7 +4082,7 @@ again: ...@@ -4082,7 +4082,7 @@ again:
end: end:
/* clean up */ /* clean up */
if (s->current_picture_ptr && s->current_picture_ptr->owner2 == s && if (s->current_picture_ptr && s->current_picture_ptr->owner2 == s &&
!s->dropable) { !s->droppable) {
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX,
s->picture_structure == PICT_BOTTOM_FIELD); s->picture_structure == PICT_BOTTOM_FIELD);
} }
......
...@@ -594,7 +594,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, ...@@ -594,7 +594,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
// B-frame info // B-frame info
s->max_b_frames = s1->max_b_frames; s->max_b_frames = s1->max_b_frames;
s->low_delay = s1->low_delay; s->low_delay = s1->low_delay;
s->dropable = s1->dropable; s->droppable = s1->droppable;
// DivX handling (doesn't work) // DivX handling (doesn't work)
s->divx_packed = s1->divx_packed; s->divx_packed = s1->divx_packed;
...@@ -1348,7 +1348,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -1348,7 +1348,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
} }
pic->f.reference = 0; pic->f.reference = 0;
if (!s->dropable) { if (!s->droppable) {
if (s->codec_id == AV_CODEC_ID_H264) if (s->codec_id == AV_CODEC_ID_H264)
pic->f.reference = s->picture_structure; pic->f.reference = s->picture_structure;
else if (s->pict_type != AV_PICTURE_TYPE_B) else if (s->pict_type != AV_PICTURE_TYPE_B)
...@@ -1383,7 +1383,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -1383,7 +1383,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
if (s->pict_type != AV_PICTURE_TYPE_B) { if (s->pict_type != AV_PICTURE_TYPE_B) {
s->last_picture_ptr = s->next_picture_ptr; s->last_picture_ptr = s->next_picture_ptr;
if (!s->dropable) if (!s->droppable)
s->next_picture_ptr = s->current_picture_ptr; s->next_picture_ptr = s->current_picture_ptr;
} }
av_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", av_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
...@@ -1391,7 +1391,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -1391,7 +1391,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->last_picture_ptr ? s->last_picture_ptr->f.data[0] : NULL, s->last_picture_ptr ? s->last_picture_ptr->f.data[0] : NULL,
s->next_picture_ptr ? s->next_picture_ptr->f.data[0] : NULL, s->next_picture_ptr ? s->next_picture_ptr->f.data[0] : NULL,
s->current_picture_ptr ? s->current_picture_ptr->f.data[0] : NULL, s->current_picture_ptr ? s->current_picture_ptr->f.data[0] : NULL,
s->pict_type, s->dropable); s->pict_type, s->droppable);
if (s->codec_id != AV_CODEC_ID_H264) { if (s->codec_id != AV_CODEC_ID_H264) {
if ((s->last_picture_ptr == NULL || if ((s->last_picture_ptr == NULL ||
......
...@@ -346,7 +346,7 @@ typedef struct MpegEncContext { ...@@ -346,7 +346,7 @@ typedef struct MpegEncContext {
int vbv_delay; int vbv_delay;
int last_pict_type; //FIXME removes int last_pict_type; //FIXME removes
int last_non_b_pict_type; ///< used for mpeg4 gmc b-frames & ratecontrol int last_non_b_pict_type; ///< used for mpeg4 gmc b-frames & ratecontrol
int dropable; int droppable;
int frame_rate_index; int frame_rate_index;
AVRational mpeg2_frame_rate_ext; AVRational mpeg2_frame_rate_ext;
int last_lambda_for[5]; ///< last lambda for a specific pict type int last_lambda_for[5]; ///< last lambda for a specific pict type
......
...@@ -5571,7 +5571,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, ...@@ -5571,7 +5571,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
/* skip B-frames if we don't have reference frames */ /* skip B-frames if we don't have reference frames */
if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->dropable)) { if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->droppable)) {
goto err; goto err;
} }
if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) || if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
......
...@@ -25,23 +25,20 @@ ...@@ -25,23 +25,20 @@
#include "libavcodec/get_bits.h" #include "libavcodec/get_bits.h"
#include "avformat.h" #include "avformat.h"
#include "mpegts.h" #include "mpegts.h"
#include "url.h"
#include "network.h" #include "network.h"
#include "url.h"
#include "rtpdec.h" #include "rtpdec.h"
#include "rtpdec_formats.h" #include "rtpdec_formats.h"
//#define DEBUG /* TODO:
* - add RTCP statistics reporting (should be optional).
/* TODO: - add RTCP statistics reporting (should be optional). *
* - add support for H.263/MPEG-4 packetized output: IDEA: send a
- add support for h263/mpeg4 packetized output : IDEA: send a * buffer to 'rtp_write_packet' contains all the packets for ONE
buffer to 'rtp_write_packet' contains all the packets for ONE * frame. Each packet should have a four byte header containing
frame. Each packet should have a four byte header containing * the length in big-endian format (same trick as
the length in big endian format (same trick as * 'ffio_open_dyn_packet_buf').
'ffio_open_dyn_packet_buf') */
*/
static RTPDynamicProtocolHandler realmedia_mp3_dynamic_handler = { static RTPDynamicProtocolHandler realmedia_mp3_dynamic_handler = {
.enc_name = "X-MP3-draft-00", .enc_name = "X-MP3-draft-00",
...@@ -62,12 +59,12 @@ static RTPDynamicProtocolHandler opus_dynamic_handler = { ...@@ -62,12 +59,12 @@ static RTPDynamicProtocolHandler opus_dynamic_handler = {
}; };
/* statistics functions */ /* statistics functions */
static RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler= NULL; static RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler = NULL;
void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler) void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler)
{ {
handler->next= RTPFirstDynamicPayloadHandler; handler->next = RTPFirstDynamicPayloadHandler;
RTPFirstDynamicPayloadHandler= handler; RTPFirstDynamicPayloadHandler = handler;
} }
void av_register_rtp_dynamic_payload_handlers(void) void av_register_rtp_dynamic_payload_handlers(void)
...@@ -131,7 +128,8 @@ RTPDynamicProtocolHandler *ff_rtp_handler_find_by_id(int id, ...@@ -131,7 +128,8 @@ RTPDynamicProtocolHandler *ff_rtp_handler_find_by_id(int id,
return NULL; return NULL;
} }
static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len) static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf,
int len)
{ {
int payload_len; int payload_len;
while (len >= 4) { while (len >= 4) {
...@@ -140,7 +138,8 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int l ...@@ -140,7 +138,8 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int l
switch (buf[1]) { switch (buf[1]) {
case RTCP_SR: case RTCP_SR:
if (payload_len < 20) { if (payload_len < 20) {
av_log(NULL, AV_LOG_ERROR, "Invalid length for RTCP SR packet\n"); av_log(NULL, AV_LOG_ERROR,
"Invalid length for RTCP SR packet\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
...@@ -164,7 +163,7 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int l ...@@ -164,7 +163,7 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int l
return -1; return -1;
} }
#define RTP_SEQ_MOD (1<<16) #define RTP_SEQ_MOD (1 << 16)
static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence) static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence)
{ {
...@@ -174,8 +173,9 @@ static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence) ...@@ -174,8 +173,9 @@ static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence)
} }
/* /*
* called whenever there is a large jump in sequence numbers, or when they get out of probation... * Called whenever there is a large jump in sequence numbers,
*/ * or when they get out of probation...
*/
static void rtp_init_sequence(RTPStatistics *s, uint16_t seq) static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
{ {
s->max_seq = seq; s->max_seq = seq;
...@@ -189,9 +189,7 @@ static void rtp_init_sequence(RTPStatistics *s, uint16_t seq) ...@@ -189,9 +189,7 @@ static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
s->transit = 0; s->transit = 0;
} }
/* /* Returns 1 if we should handle this packet. */
* returns 1 if we should handle this packet.
*/
static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq) static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
{ {
uint16_t udelta = seq - s->max_seq; uint16_t udelta = seq - s->max_seq;
...@@ -199,7 +197,8 @@ static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq) ...@@ -199,7 +197,8 @@ static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
const int MAX_MISORDER = 100; const int MAX_MISORDER = 100;
const int MIN_SEQUENTIAL = 2; const int MIN_SEQUENTIAL = 2;
/* source not valid until MIN_SEQUENTIAL packets with sequence seq. numbers have been received */ /* source not valid until MIN_SEQUENTIAL packets with sequence
* seq. numbers have been received */
if (s->probation) { if (s->probation) {
if (seq == s->max_seq + 1) { if (seq == s->max_seq + 1) {
s->probation--; s->probation--;
...@@ -223,7 +222,8 @@ static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq) ...@@ -223,7 +222,8 @@ static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
} else if (udelta <= RTP_SEQ_MOD - MAX_MISORDER) { } else if (udelta <= RTP_SEQ_MOD - MAX_MISORDER) {
// sequence made a large jump... // sequence made a large jump...
if (seq == s->bad_seq) { if (seq == s->bad_seq) {
// two sequential packets-- assume that the other side restarted without telling us; just resync. /* two sequential packets -- assume that the other side
* restarted without telling us; just resync. */
rtp_init_sequence(s, seq); rtp_init_sequence(s, seq);
} else { } else {
s->bad_seq = (seq + 1) & (RTP_SEQ_MOD - 1); s->bad_seq = (seq + 1) & (RTP_SEQ_MOD - 1);
...@@ -256,7 +256,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) ...@@ -256,7 +256,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
return -1; return -1;
/* TODO: I think this is way too often; RFC 1889 has algorithm for this */ /* TODO: I think this is way too often; RFC 1889 has algorithm for this */
/* XXX: mpeg pts hardcoded. RTCP send every 0.5 seconds */ /* XXX: MPEG pts hardcoded. RTCP send every 0.5 seconds */
s->octet_count += count; s->octet_count += count;
rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) / rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
RTCP_TX_RATIO_DEN; RTCP_TX_RATIO_DEN;
...@@ -318,23 +318,22 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) ...@@ -318,23 +318,22 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
avio_w8(pb, len); avio_w8(pb, len);
avio_write(pb, s->hostname, len); avio_write(pb, s->hostname, len);
// padding // padding
for (len = (6 + len) % 4; len % 4; len++) { for (len = (6 + len) % 4; len % 4; len++)
avio_w8(pb, 0); avio_w8(pb, 0);
}
avio_flush(pb); avio_flush(pb);
len = avio_close_dyn_buf(pb, &buf); len = avio_close_dyn_buf(pb, &buf);
if ((len > 0) && buf) { if ((len > 0) && buf) {
int av_unused result; int av_unused result;
av_dlog(s->ic, "sending %d bytes of RR\n", len); av_dlog(s->ic, "sending %d bytes of RR\n", len);
result= ffurl_write(s->rtp_ctx, buf, len); result = ffurl_write(s->rtp_ctx, buf, len);
av_dlog(s->ic, "result from ffurl_write: %d\n", result); av_dlog(s->ic, "result from ffurl_write: %d\n", result);
av_free(buf); av_free(buf);
} }
return 0; return 0;
} }
void ff_rtp_send_punch_packets(URLContext* rtp_handle) void ff_rtp_send_punch_packets(URLContext *rtp_handle)
{ {
AVIOContext *pb; AVIOContext *pb;
uint8_t *buf; uint8_t *buf;
...@@ -372,13 +371,14 @@ void ff_rtp_send_punch_packets(URLContext* rtp_handle) ...@@ -372,13 +371,14 @@ void ff_rtp_send_punch_packets(URLContext* rtp_handle)
av_free(buf); av_free(buf);
} }
/** /**
* open a new RTP parse context for stream 'st'. 'st' can be NULL for * open a new RTP parse context for stream 'st'. 'st' can be NULL for
* MPEG2TS streams to indicate that they should be demuxed inside the * MPEG2-TS streams to indicate that they should be demuxed inside the
* rtp demux (otherwise AV_CODEC_ID_MPEG2TS packets are returned) * rtp demux (otherwise AV_CODEC_ID_MPEG2TS packets are returned)
*/ */
RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size) RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st,
URLContext *rtpc, int payload_type,
int queue_size)
{ {
RTPDemuxContext *s; RTPDemuxContext *s;
...@@ -399,7 +399,7 @@ RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext ...@@ -399,7 +399,7 @@ RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext
return NULL; return NULL;
} }
} else if (st) { } else if (st) {
switch(st->codec->codec_id) { switch (st->codec->codec_id) {
case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO: case AV_CODEC_ID_MPEG2VIDEO:
case AV_CODEC_ID_MP2: case AV_CODEC_ID_MP2:
...@@ -436,7 +436,8 @@ void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, ...@@ -436,7 +436,8 @@ void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx,
} }
/** /**
* This was the second switch in rtp_parse packet. Normalizes time, if required, sets stream_index, etc. * This was the second switch in rtp_parse packet.
* Normalizes time, if required, sets stream_index, etc.
*/ */
static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp) static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp)
{ {
...@@ -452,7 +453,9 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam ...@@ -452,7 +453,9 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam
/* compute pts from timestamp with received ntp_time */ /* compute pts from timestamp with received ntp_time */
delta_timestamp = timestamp - s->last_rtcp_timestamp; delta_timestamp = timestamp - s->last_rtcp_timestamp;
/* convert to the PTS timebase */ /* convert to the PTS timebase */
addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, s->st->time_base.den, (uint64_t)s->st->time_base.num << 32); addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time,
s->st->time_base.den,
(uint64_t) s->st->time_base.num << 32);
pkt->pts = s->range_start_offset + s->rtcp_ts_offset + addend + pkt->pts = s->range_start_offset + s->rtcp_ts_offset + addend +
delta_timestamp; delta_timestamp;
return; return;
...@@ -460,13 +463,15 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam ...@@ -460,13 +463,15 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam
if (!s->base_timestamp) if (!s->base_timestamp)
s->base_timestamp = timestamp; s->base_timestamp = timestamp;
/* assume that the difference is INT32_MIN < x < INT32_MAX, but allow the first timestamp to exceed INT32_MAX */ /* assume that the difference is INT32_MIN < x < INT32_MAX,
* but allow the first timestamp to exceed INT32_MAX */
if (!s->timestamp) if (!s->timestamp)
s->unwrapped_timestamp += timestamp; s->unwrapped_timestamp += timestamp;
else else
s->unwrapped_timestamp += (int32_t)(timestamp - s->timestamp); s->unwrapped_timestamp += (int32_t)(timestamp - s->timestamp);
s->timestamp = timestamp; s->timestamp = timestamp;
pkt->pts = s->unwrapped_timestamp + s->range_start_offset - s->base_timestamp; pkt->pts = s->unwrapped_timestamp + s->range_start_offset -
s->base_timestamp;
} }
static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt, static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
...@@ -477,7 +482,7 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt, ...@@ -477,7 +482,7 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
int ext; int ext;
AVStream *st; AVStream *st;
uint32_t timestamp; uint32_t timestamp;
int rv= 0; int rv = 0;
ext = buf[0] & 0x10; ext = buf[0] & 0x10;
payload_type = buf[1] & 0x7f; payload_type = buf[1] & 0x7f;
...@@ -495,9 +500,9 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt, ...@@ -495,9 +500,9 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
st = s->st; st = s->st;
// only do something with this if all the rtp checks pass... // only do something with this if all the rtp checks pass...
if(!rtp_valid_packet_in_sequence(&s->statistics, seq)) if (!rtp_valid_packet_in_sequence(&s->statistics, seq)) {
{ av_log(st ? st->codec : NULL, AV_LOG_ERROR,
av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n", "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
payload_type, seq, ((s->seq + 1) & 0xffff)); payload_type, seq, ((s->seq + 1) & 0xffff));
return -1; return -1;
} }
...@@ -528,7 +533,7 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt, ...@@ -528,7 +533,7 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
} }
if (!st) { if (!st) {
/* specific MPEG2TS demux support */ /* specific MPEG2-TS demux support */
ret = ff_mpegts_parse_packet(s->ts, pkt, buf, len); ret = ff_mpegts_parse_packet(s->ts, pkt, buf, len);
/* The only error that can be returned from ff_mpegts_parse_packet /* The only error that can be returned from ff_mpegts_parse_packet
* is "no more data to return from the provided buffer", so return * is "no more data to return from the provided buffer", so return
...@@ -546,11 +551,12 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt, ...@@ -546,11 +551,12 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
rv = s->parse_packet(s->ic, s->dynamic_protocol_context, rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
s->st, pkt, &timestamp, buf, len, flags); s->st, pkt, &timestamp, buf, len, flags);
} else { } else {
// at this point, the RTP header has been stripped; This is ASSUMING that there is only 1 CSRC, which in't wise. /* At this point, the RTP header has been stripped;
switch(st->codec->codec_id) { * This is ASSUMING that there is only 1 CSRC, which isn't wise. */
switch (st->codec->codec_id) {
case AV_CODEC_ID_MP2: case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3: case AV_CODEC_ID_MP3:
/* better than nothing: skip mpeg audio RTP header */ /* better than nothing: skip MPEG audio RTP header */
if (len <= 4) if (len <= 4)
return -1; return -1;
h = AV_RB32(buf); h = AV_RB32(buf);
...@@ -562,14 +568,14 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt, ...@@ -562,14 +568,14 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
break; break;
case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO: case AV_CODEC_ID_MPEG2VIDEO:
/* better than nothing: skip mpeg video RTP header */ /* better than nothing: skip MPEG video RTP header */
if (len <= 4) if (len <= 4)
return -1; return -1;
h = AV_RB32(buf); h = AV_RB32(buf);
buf += 4; buf += 4;
len -= 4; len -= 4;
if (h & (1 << 26)) { if (h & (1 << 26)) {
/* mpeg2 */ /* MPEG-2 */
if (len <= 4) if (len <= 4)
return -1; return -1;
buf += 4; buf += 4;
...@@ -672,10 +678,10 @@ static int rtp_parse_queued_packet(RTPDemuxContext *s, AVPacket *pkt) ...@@ -672,10 +678,10 @@ static int rtp_parse_queued_packet(RTPDemuxContext *s, AVPacket *pkt)
static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
uint8_t **bufptr, int len) uint8_t **bufptr, int len)
{ {
uint8_t* buf = bufptr ? *bufptr : NULL; uint8_t *buf = bufptr ? *bufptr : NULL;
int ret, flags = 0; int ret, flags = 0;
uint32_t timestamp; uint32_t timestamp;
int rv= 0; int rv = 0;
if (!buf) { if (!buf) {
/* If parsing of the previous packet actually returned 0 or an error, /* If parsing of the previous packet actually returned 0 or an error,
...@@ -684,11 +690,11 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, ...@@ -684,11 +690,11 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
if (s->prev_ret <= 0) if (s->prev_ret <= 0)
return rtp_parse_queued_packet(s, pkt); return rtp_parse_queued_packet(s, pkt);
/* return the next packets, if any */ /* return the next packets, if any */
if(s->st && s->parse_packet) { if (s->st && s->parse_packet) {
/* timestamp should be overwritten by parse_packet, if not, /* timestamp should be overwritten by parse_packet, if not,
* the packet is left with pts == AV_NOPTS_VALUE */ * the packet is left with pts == AV_NOPTS_VALUE */
timestamp = RTP_NOTS_VALUE; timestamp = RTP_NOTS_VALUE;
rv= s->parse_packet(s->ic, s->dynamic_protocol_context, rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
s->st, pkt, &timestamp, NULL, 0, flags); s->st, pkt, &timestamp, NULL, 0, flags);
finalize_packet(s, pkt, timestamp); finalize_packet(s, pkt, timestamp);
return rv; return rv;
...@@ -789,14 +795,16 @@ int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p, ...@@ -789,14 +795,16 @@ int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p,
} }
// remove protocol identifier // remove protocol identifier
while (*p && *p == ' ') p++; // strip spaces while (*p && *p == ' ')
while (*p && *p != ' ') p++; // eat protocol identifier p++; // strip spaces
while (*p && *p == ' ') p++; // strip trailing spaces while (*p && *p != ' ')
p++; // eat protocol identifier
while (*p && *p == ' ')
p++; // strip trailing spaces
while (ff_rtsp_next_attr_and_value(&p, while (ff_rtsp_next_attr_and_value(&p,
attr, sizeof(attr), attr, sizeof(attr),
value, value_size)) { value, value_size)) {
res = parse_fmtp(stream, data, attr, value); res = parse_fmtp(stream, data, attr, value);
if (res < 0 && res != AVERROR_PATCHWELCOME) { if (res < 0 && res != AVERROR_PATCHWELCOME) {
av_free(value); av_free(value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment