Commit 7333798c authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  libopenjpeg: support YUV and deep RGB pixel formats
  Fix typo in v410 decoder.
  vf_yadif: unset cur_buf on the input link.
  vf_overlay: ensure the overlay frame does not get leaked.
  vf_overlay: prevent premature freeing of cur_buf
  Support urlencoded http authentication credentials
  rtmp: Return an error when the client bandwidth is incorrect
  rtmp: Return proper error code in handle_server_bw
  rtmp: Return proper error code in handle_client_bw
  rtmp: Return proper error codes in handle_chunk_size
  lavr: x86: add missing vzeroupper in ff_mix_1_to_2_fltp_flt()
  vp8: Replace x*155/100 by x*101581>>16.
  vp3: don't use calls to inline asm in yasm code.
  x86/dsputil: put inline asm under HAVE_INLINE_ASM.
  dsputil_mmx: fix incorrect assembly code
  rtmp: Factorize the code by adding handle_invoke
  rtmp: Factorize the code by adding handle_chunk_size
  rtmp: Factorize the code by adding handle_ping
  rtmp: Factorize the code by adding handle_client_bw
  rtmp: Factorize the code by adding handle_server_bw

Conflicts:
	libavcodec/libopenjpegdec.c
	libavcodec/x86/dsputil_mmx.c
	libavfilter/vf_overlay.c
	libavformat/Makefile
	libavformat/version.h
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 307a20cc 44dc9c6a
...@@ -125,7 +125,7 @@ static const struct algo idct_tab[] = { ...@@ -125,7 +125,7 @@ static const struct algo idct_tab[] = {
{ "INT", ff_j_rev_dct, MMX_PERM }, { "INT", ff_j_rev_dct, MMX_PERM },
{ "SIMPLE-C", ff_simple_idct_8, NO_PERM }, { "SIMPLE-C", ff_simple_idct_8, NO_PERM },
#if HAVE_MMX #if HAVE_MMX && HAVE_INLINE_ASM
#if CONFIG_GPL #if CONFIG_GPL
{ "LIBMPEG2-MMX", ff_mmx_idct, MMX_PERM, AV_CPU_FLAG_MMX, 1 }, { "LIBMPEG2-MMX", ff_mmx_idct, MMX_PERM, AV_CPU_FLAG_MMX, 1 },
{ "LIBMPEG2-MMX2", ff_mmxext_idct, MMX_PERM, AV_CPU_FLAG_MMX2, 1 }, { "LIBMPEG2-MMX2", ff_mmxext_idct, MMX_PERM, AV_CPU_FLAG_MMX2, 1 },
......
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
#define OPJ_STATIC #define OPJ_STATIC
#include <openjpeg.h> #include <openjpeg.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/pixfmt.h" #include "libavutil/pixfmt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "avcodec.h" #include "avcodec.h"
#include "thread.h" #include "thread.h"
...@@ -293,15 +293,12 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, ...@@ -293,15 +293,12 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
avcodec_set_dimensions(avctx, width, height); avcodec_set_dimensions(avctx, width, height);
if (avctx->pix_fmt != PIX_FMT_NONE) { if (avctx->pix_fmt != PIX_FMT_NONE)
if (!libopenjpeg_matches_pix_fmt(image, avctx->pix_fmt)) { if (!libopenjpeg_matches_pix_fmt(image, avctx->pix_fmt))
avctx->pix_fmt = PIX_FMT_NONE; avctx->pix_fmt = PIX_FMT_NONE;
}
}
if (avctx->pix_fmt == PIX_FMT_NONE) { if (avctx->pix_fmt == PIX_FMT_NONE)
avctx->pix_fmt = libopenjpeg_guess_pix_fmt(image); avctx->pix_fmt = libopenjpeg_guess_pix_fmt(image);
}
if (avctx->pix_fmt == PIX_FMT_NONE) { if (avctx->pix_fmt == PIX_FMT_NONE) {
av_log(avctx, AV_LOG_ERROR, "Unable to determine pixel format\n"); av_log(avctx, AV_LOG_ERROR, "Unable to determine pixel format\n");
...@@ -331,9 +328,10 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, ...@@ -331,9 +328,10 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
} }
opj_image_destroy(image); opj_image_destroy(image);
// Decode the codestream. // Decode the codestream
image = opj_decode_with_info(dec, stream, NULL); image = opj_decode_with_info(dec, stream, NULL);
opj_cio_close(stream); opj_cio_close(stream);
if (!image) { if (!image) {
av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n"); av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n");
goto done; goto done;
......
...@@ -249,12 +249,13 @@ static void get_quants(VP8Context *s) ...@@ -249,12 +249,13 @@ static void get_quants(VP8Context *s)
} else } else
base_qi = yac_qi; base_qi = yac_qi;
s->qmat[i].luma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + ydc_delta , 7)]; s->qmat[i].luma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + ydc_delta , 7)];
s->qmat[i].luma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi , 7)]; s->qmat[i].luma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi , 7)];
s->qmat[i].luma_dc_qmul[0] = 2 * vp8_dc_qlookup[av_clip_uintp2(base_qi + y2dc_delta, 7)]; s->qmat[i].luma_dc_qmul[0] = 2 * vp8_dc_qlookup[av_clip_uintp2(base_qi + y2dc_delta, 7)];
s->qmat[i].luma_dc_qmul[1] = 155 * vp8_ac_qlookup[av_clip_uintp2(base_qi + y2ac_delta, 7)] / 100; /* 101581>>16 is equivalent to 155/100 */
s->qmat[i].chroma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + uvdc_delta, 7)]; s->qmat[i].luma_dc_qmul[1] = (101581 * vp8_ac_qlookup[av_clip_uintp2(base_qi + y2ac_delta, 7)]) >> 16;
s->qmat[i].chroma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi + uvac_delta, 7)]; s->qmat[i].chroma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + uvdc_delta, 7)];
s->qmat[i].chroma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi + uvac_delta, 7)];
s->qmat[i].luma_dc_qmul[1] = FFMAX(s->qmat[i].luma_dc_qmul[1], 8); s->qmat[i].luma_dc_qmul[1] = FFMAX(s->qmat[i].luma_dc_qmul[1], 8);
s->qmat[i].chroma_qmul[0] = FFMIN(s->qmat[i].chroma_qmul[0], 132); s->qmat[i].chroma_qmul[0] = FFMIN(s->qmat[i].chroma_qmul[0], 132);
......
This diff is collapsed.
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
#if HAVE_INLINE_ASM
/***********************************/ /***********************************/
/* motion compensation */ /* motion compensation */
...@@ -1191,7 +1193,7 @@ H264_MC_816(H264_MC_H, ssse3) ...@@ -1191,7 +1193,7 @@ H264_MC_816(H264_MC_H, ssse3)
H264_MC_816(H264_MC_HV, ssse3) H264_MC_816(H264_MC_HV, ssse3)
#endif #endif
#endif /* HAVE_INLINE_ASM */
//10bit //10bit
#define LUMA_MC_OP(OP, NUM, DEPTH, TYPE, OPT) \ #define LUMA_MC_OP(OP, NUM, DEPTH, TYPE, OPT) \
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
#if HAVE_INLINE_ASM
#define ROW_SHIFT 11 #define ROW_SHIFT 11
#define COL_SHIFT 6 #define COL_SHIFT 6
...@@ -626,3 +628,5 @@ declare_idct (ff_mmxext_idct, mmxext_table, ...@@ -626,3 +628,5 @@ declare_idct (ff_mmxext_idct, mmxext_table,
declare_idct (ff_mmx_idct, mmx_table, declare_idct (ff_mmx_idct, mmx_table,
mmx_row_head, mmx_row, mmx_row_tail, mmx_row_mid) mmx_row_head, mmx_row, mmx_row_tail, mmx_row_mid)
#endif /* HAVE_INLINE_ASM */
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include "libavcodec/avcodec.h" #include "libavcodec/avcodec.h"
#include "idct_xvid.h" #include "idct_xvid.h"
#if HAVE_INLINE_ASM
//============================================================================= //=============================================================================
// Macros and other preprocessor constants // Macros and other preprocessor constants
//============================================================================= //=============================================================================
...@@ -523,3 +525,5 @@ __asm__ volatile( ...@@ -523,3 +525,5 @@ __asm__ volatile(
DCT_8_INV_COL(8(%0), 8(%0)) DCT_8_INV_COL(8(%0), 8(%0))
:: "r"(block), "r"(rounder_0), "r"(tab_i_04_xmm), "r"(tg_1_16)); :: "r"(block), "r"(rounder_0), "r"(tab_i_04_xmm), "r"(tg_1_16));
} }
#endif /* HAVE_INLINE_ASM */
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include "idct_xvid.h" #include "idct_xvid.h"
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
#if HAVE_INLINE_ASM
/** /**
* @file * @file
* @brief SSE2 idct compatible with xvidmmx * @brief SSE2 idct compatible with xvidmmx
...@@ -401,3 +403,5 @@ void ff_idct_xvid_sse2_add(uint8_t *dest, int line_size, short *block) ...@@ -401,3 +403,5 @@ void ff_idct_xvid_sse2_add(uint8_t *dest, int line_size, short *block)
ff_idct_xvid_sse2(block); ff_idct_xvid_sse2(block);
ff_add_pixels_clamped_mmx(block, dest, line_size); ff_add_pixels_clamped_mmx(block, dest, line_size);
} }
#endif /* HAVE_INLINE_ASM */
...@@ -194,10 +194,12 @@ void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp) ...@@ -194,10 +194,12 @@ void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp)
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
c->put_chroma_pixels_tab[0] = ff_put_rv40_chroma_mc8_mmx; c->put_chroma_pixels_tab[0] = ff_put_rv40_chroma_mc8_mmx;
c->put_chroma_pixels_tab[1] = ff_put_rv40_chroma_mc4_mmx; c->put_chroma_pixels_tab[1] = ff_put_rv40_chroma_mc4_mmx;
#if HAVE_INLINE_ASM
c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_mmx; c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_mmx;
c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_mmx; c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_mmx;
c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_mmx; c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_mmx;
c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_mmx; c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_mmx;
#endif /* HAVE_INLINE_ASM */
#if ARCH_X86_32 #if ARCH_X86_32
QPEL_MC_SET(put_, _mmx) QPEL_MC_SET(put_, _mmx)
#endif #endif
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "libavcodec/simple_idct.h" #include "libavcodec/simple_idct.h"
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
#if HAVE_INLINE_ASM
/* /*
23170.475006 23170.475006
22725.260826 22725.260826
...@@ -1161,3 +1163,5 @@ void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block) ...@@ -1161,3 +1163,5 @@ void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block)
idct(block); idct(block);
ff_add_pixels_clamped_mmx(block, dest, line_size); ff_add_pixels_clamped_mmx(block, dest, line_size);
} }
#endif /* HAVE_INLINE_ASM */
...@@ -38,13 +38,11 @@ cextern pb_1 ...@@ -38,13 +38,11 @@ cextern pb_1
cextern pb_3 cextern pb_3
cextern pb_7 cextern pb_7
cextern pb_1F cextern pb_1F
cextern pb_80
cextern pb_81 cextern pb_81
cextern pw_8 cextern pw_8
cextern put_signed_pixels_clamped_mmx
cextern add_pixels_clamped_mmx
SECTION .text SECTION .text
; this is off by one or two for some cases when filter_limit is greater than 63 ; this is off by one or two for some cases when filter_limit is greater than 63
...@@ -523,56 +521,96 @@ cglobal vp3_h_loop_filter_mmx2, 3, 4 ...@@ -523,56 +521,96 @@ cglobal vp3_h_loop_filter_mmx2, 3, 4
PUT_BLOCK 0, 1, 2, 3, 4, 5, 6, 7 PUT_BLOCK 0, 1, 2, 3, 4, 5, 6, 7
%endmacro %endmacro
%macro vp3_idct_funcs 3 %macro vp3_idct_funcs 1
cglobal vp3_idct_put_%1, 3, %3, %2 cglobal vp3_idct_put_%1, 3, 4, 9
VP3_IDCT_%1 r2 VP3_IDCT_%1 r2
%if ARCH_X86_64
mov r3, r2 movsxdifnidn r1, r1d
mov r2, r1 mova m4, [pb_80]
mov r1, r0 lea r3, [r1*3]
mov r0, r3 %assign %%i 0
%rep 16/mmsize
mova m0, [r2+mmsize*0+%%i]
mova m1, [r2+mmsize*2+%%i]
mova m2, [r2+mmsize*4+%%i]
mova m3, [r2+mmsize*6+%%i]
packsswb m0, [r2+mmsize*1+%%i]
packsswb m1, [r2+mmsize*3+%%i]
packsswb m2, [r2+mmsize*5+%%i]
packsswb m3, [r2+mmsize*7+%%i]
paddb m0, m4
paddb m1, m4
paddb m2, m4
paddb m3, m4
movq [r0 ], m0
%if mmsize == 8
movq [r0+r1 ], m1
movq [r0+r1*2], m2
movq [r0+r3 ], m3
%else %else
mov r0m, r2 movhps [r0+r1 ], m0
mov r1m, r0 movq [r0+r1*2], m1
mov r2m, r1 movhps [r0+r3 ], m1
%endif %endif
%if WIN64 %if %%i == 0
call put_signed_pixels_clamped_mmx lea r0, [r0+r1*4]
RET %endif
%else %if mmsize == 16
jmp put_signed_pixels_clamped_mmx movq [r0 ], m2
movhps [r0+r1 ], m2
movq [r0+r1*2], m3
movhps [r0+r3 ], m3
%endif %endif
%assign %%i %%i+64
%endrep
RET
cglobal vp3_idct_add_%1, 3, %3, %2 cglobal vp3_idct_add_%1, 3, 4, 9
VP3_IDCT_%1 r2 VP3_IDCT_%1 r2
%if ARCH_X86_64
mov r3, r2 mov r3, 4
mov r2, r1 pxor m4, m4
mov r1, r0 movsxdifnidn r1, r1d
mov r0, r3 .loop:
%else movq m0, [r0]
mov r0m, r2 movq m1, [r0+r1]
mov r1m, r0 %if mmsize == 8
mov r2m, r1 mova m2, m0
mova m3, m1
%endif %endif
%if WIN64 punpcklbw m0, m4
call add_pixels_clamped_mmx punpcklbw m1, m4
RET %if mmsize == 8
%else punpckhbw m2, m4
jmp add_pixels_clamped_mmx punpckhbw m3, m4
%endif
paddsw m0, [r2+ 0]
paddsw m1, [r2+16]
%if mmsize == 8
paddsw m2, [r2+ 8]
paddsw m3, [r2+24]
packuswb m0, m2
packuswb m1, m3
%else ; mmsize == 16
packuswb m0, m1
%endif %endif
movq [r0 ], m0
%if mmsize == 8
movq [r0+r1], m1
%else ; mmsize == 16
movhps [r0+r1], m0
%endif
lea r0, [r0+r1*2]
add r2, 32
dec r3
jg .loop
RET
%endmacro %endmacro
%if ARCH_X86_64
%define REGS 4
%else
%define REGS 3
%endif
INIT_MMX INIT_MMX
vp3_idct_funcs mmx, 0, REGS vp3_idct_funcs mmx
INIT_XMM INIT_XMM
vp3_idct_funcs sse2, 9, REGS vp3_idct_funcs sse2
%undef REGS
%macro DC_ADD 0 %macro DC_ADD 0
movq m2, [r0 ] movq m2, [r0 ]
......
...@@ -222,6 +222,7 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) ...@@ -222,6 +222,7 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
yadif->prev = yadif->cur; yadif->prev = yadif->cur;
yadif->cur = yadif->next; yadif->cur = yadif->next;
yadif->next = picref; yadif->next = picref;
link->cur_buf = NULL;
if (!yadif->cur) if (!yadif->cur)
return 0; return 0;
......
...@@ -299,9 +299,10 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \ ...@@ -299,9 +299,10 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \
rtpdec_svq3.o \ rtpdec_svq3.o \
rtpdec_vp8.o \ rtpdec_vp8.o \
rtpdec_xiph.o rtpdec_xiph.o
OBJS-$(CONFIG_RTSP_DEMUXER) += rtsp.o rtspdec.o httpauth.o OBJS-$(CONFIG_RTSP_DEMUXER) += rtsp.o rtspdec.o httpauth.o \
urldecode.o
OBJS-$(CONFIG_RTSP_MUXER) += rtsp.o rtspenc.o httpauth.o \ OBJS-$(CONFIG_RTSP_MUXER) += rtsp.o rtspenc.o httpauth.o \
rtpenc_chain.o rtpenc_chain.o urldecode.o
OBJS-$(CONFIG_SAMI_DEMUXER) += samidec.o OBJS-$(CONFIG_SAMI_DEMUXER) += samidec.o
OBJS-$(CONFIG_SAP_DEMUXER) += sapdec.o OBJS-$(CONFIG_SAP_DEMUXER) += sapdec.o
OBJS-$(CONFIG_SAP_MUXER) += sapenc.o rtpenc_chain.o OBJS-$(CONFIG_SAP_MUXER) += sapenc.o rtpenc_chain.o
...@@ -379,9 +380,9 @@ OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL) += rtmphttp.o ...@@ -379,9 +380,9 @@ OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL) += rtmphttp.o
OBJS-$(CONFIG_FILE_PROTOCOL) += file.o OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
OBJS-$(CONFIG_GOPHER_PROTOCOL) += gopher.o OBJS-$(CONFIG_GOPHER_PROTOCOL) += gopher.o
OBJS-$(CONFIG_HLS_PROTOCOL) += hlsproto.o OBJS-$(CONFIG_HLS_PROTOCOL) += hlsproto.o
OBJS-$(CONFIG_HTTP_PROTOCOL) += http.o httpauth.o OBJS-$(CONFIG_HTTP_PROTOCOL) += http.o httpauth.o urldecode.o
OBJS-$(CONFIG_HTTPPROXY_PROTOCOL) += http.o httpauth.o OBJS-$(CONFIG_HTTPPROXY_PROTOCOL) += http.o httpauth.o urldecode.o
OBJS-$(CONFIG_HTTPS_PROTOCOL) += http.o httpauth.o OBJS-$(CONFIG_HTTPS_PROTOCOL) += http.o httpauth.o urldecode.o
OBJS-$(CONFIG_MMSH_PROTOCOL) += mmsh.o mms.o asf.o OBJS-$(CONFIG_MMSH_PROTOCOL) += mmsh.o mms.o asf.o
OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o asf.o OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o asf.o
OBJS-$(CONFIG_MD5_PROTOCOL) += md5proto.o OBJS-$(CONFIG_MD5_PROTOCOL) += md5proto.o
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "internal.h" #include "internal.h"
#include "libavutil/random_seed.h" #include "libavutil/random_seed.h"
#include "libavutil/md5.h" #include "libavutil/md5.h"
#include "urldecode.h"
#include "avformat.h" #include "avformat.h"
#include <ctype.h> #include <ctype.h>
...@@ -251,18 +252,28 @@ char *ff_http_auth_create_response(HTTPAuthState *state, const char *auth, ...@@ -251,18 +252,28 @@ char *ff_http_auth_create_response(HTTPAuthState *state, const char *auth,
return NULL; return NULL;
if (state->auth_type == HTTP_AUTH_BASIC) { if (state->auth_type == HTTP_AUTH_BASIC) {
int auth_b64_len = AV_BASE64_SIZE(strlen(auth)); int auth_b64_len, len;
int len = auth_b64_len + 30; char *ptr, *decoded_auth = ff_urldecode(auth);
char *ptr;
if (!decoded_auth)
return NULL;
auth_b64_len = AV_BASE64_SIZE(strlen(decoded_auth));
len = auth_b64_len + 30;
authstr = av_malloc(len); authstr = av_malloc(len);
if (!authstr) if (!authstr) {
av_free(decoded_auth);
return NULL; return NULL;
}
snprintf(authstr, len, "Authorization: Basic "); snprintf(authstr, len, "Authorization: Basic ");
ptr = authstr + strlen(authstr); ptr = authstr + strlen(authstr);
av_base64_encode(ptr, auth_b64_len, auth, strlen(auth)); av_base64_encode(ptr, auth_b64_len, decoded_auth, strlen(decoded_auth));
av_strlcat(ptr, "\r\n", len - (ptr - authstr)); av_strlcat(ptr, "\r\n", len - (ptr - authstr));
av_free(decoded_auth);
} else if (state->auth_type == HTTP_AUTH_DIGEST) { } else if (state->auth_type == HTTP_AUTH_DIGEST) {
char *username = av_strdup(auth), *password; char *username = ff_urldecode(auth), *password;
if (!username) if (!username)
return NULL; return NULL;
......
...@@ -880,75 +880,104 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) ...@@ -880,75 +880,104 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
return 0; return 0;
} }
/** static int handle_chunk_size(URLContext *s, RTMPPacket *pkt)
* Parse received packet and possibly perform some action depending on {
* the packet contents. RTMPContext *rt = s->priv_data;
* @return 0 for no errors, negative values for serious errors which prevent int ret;
* further communications, positive values for uncritical errors
*/ if (pkt->data_size != 4) {
static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) av_log(s, AV_LOG_ERROR,
"Chunk size change packet is not 4 bytes long (%d)\n",
pkt->data_size);
return AVERROR_INVALIDDATA;
}
if (!rt->is_input) {
if ((ret = ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size,
rt->prev_pkt[1])) < 0)
return ret;
}
rt->chunk_size = AV_RB32(pkt->data);
if (rt->chunk_size <= 0) {
av_log(s, AV_LOG_ERROR, "Incorrect chunk size %d\n", rt->chunk_size);
return AVERROR_INVALIDDATA;
}
av_log(s, AV_LOG_DEBUG, "New chunk size = %d\n", rt->chunk_size);
return 0;
}
static int handle_ping(URLContext *s, RTMPPacket *pkt)
{
RTMPContext *rt = s->priv_data;
int t, ret;
t = AV_RB16(pkt->data);
if (t == 6) {
if ((ret = gen_pong(s, rt, pkt)) < 0)
return ret;
}
return 0;
}
static int handle_client_bw(URLContext *s, RTMPPacket *pkt)
{ {
RTMPContext *rt = s->priv_data;
if (pkt->data_size < 4) {
av_log(s, AV_LOG_ERROR,
"Client bandwidth report packet is less than 4 bytes long (%d)\n",
pkt->data_size);
return AVERROR_INVALIDDATA;
}
rt->client_report_size = AV_RB32(pkt->data);
if (rt->client_report_size <= 0) {
av_log(s, AV_LOG_ERROR, "Incorrect client bandwidth %d\n",
rt->client_report_size);
return AVERROR_INVALIDDATA;
}
av_log(s, AV_LOG_DEBUG, "Client bandwidth = %d\n", rt->client_report_size);
rt->client_report_size >>= 1;
return 0;
}
static int handle_server_bw(URLContext *s, RTMPPacket *pkt)
{
RTMPContext *rt = s->priv_data;
rt->server_bw = AV_RB32(pkt->data);
if (rt->server_bw <= 0) {
av_log(s, AV_LOG_ERROR, "Incorrect server bandwidth %d\n",
rt->server_bw);
return AVERROR_INVALIDDATA;
}
av_log(s, AV_LOG_DEBUG, "Server bandwidth = %d\n", rt->server_bw);
return 0;
}
static int handle_invoke(URLContext *s, RTMPPacket *pkt)
{
RTMPContext *rt = s->priv_data;
int i, t; int i, t;
const uint8_t *data_end = pkt->data + pkt->data_size; const uint8_t *data_end = pkt->data + pkt->data_size;
int ret; int ret;
#ifdef DEBUG //TODO: check for the messages sent for wrong state?
ff_rtmp_packet_dump(s, pkt); if (!memcmp(pkt->data, "\002\000\006_error", 9)) {
#endif uint8_t tmpstr[256];
switch (pkt->type) { if (!ff_amf_get_field_value(pkt->data + 9, data_end,
case RTMP_PT_CHUNK_SIZE: "description", tmpstr, sizeof(tmpstr)))
if (pkt->data_size != 4) { av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr);
av_log(s, AV_LOG_ERROR, return -1;
"Chunk size change packet is not 4 bytes long (%d)\n", pkt->data_size); } else if (!memcmp(pkt->data, "\002\000\007_result", 10)) {
return -1; switch (rt->state) {
}
if (!rt->is_input)
if ((ret = ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size,
rt->prev_pkt[1])) < 0)
return ret;
rt->chunk_size = AV_RB32(pkt->data);
if (rt->chunk_size <= 0) {
av_log(s, AV_LOG_ERROR, "Incorrect chunk size %d\n", rt->chunk_size);
return -1;
}
av_log(s, AV_LOG_DEBUG, "New chunk size = %d\n", rt->chunk_size);
break;
case RTMP_PT_PING:
t = AV_RB16(pkt->data);
if (t == 6)
if ((ret = gen_pong(s, rt, pkt)) < 0)
return ret;
break;
case RTMP_PT_CLIENT_BW:
if (pkt->data_size < 4) {
av_log(s, AV_LOG_ERROR,
"Client bandwidth report packet is less than 4 bytes long (%d)\n",
pkt->data_size);
return -1;
}
av_log(s, AV_LOG_DEBUG, "Client bandwidth = %d\n", AV_RB32(pkt->data));
rt->client_report_size = AV_RB32(pkt->data) >> 1;
break;
case RTMP_PT_SERVER_BW:
rt->server_bw = AV_RB32(pkt->data);
if (rt->server_bw <= 0) {
av_log(s, AV_LOG_ERROR, "Incorrect server bandwidth %d\n", rt->server_bw);
return AVERROR(EINVAL);
}
av_log(s, AV_LOG_DEBUG, "Server bandwidth = %d\n", rt->server_bw);
break;
case RTMP_PT_INVOKE:
//TODO: check for the messages sent for wrong state?
if (!memcmp(pkt->data, "\002\000\006_error", 9)) {
uint8_t tmpstr[256];
if (!ff_amf_get_field_value(pkt->data + 9, data_end,
"description", tmpstr, sizeof(tmpstr)))
av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr);
return -1;
} else if (!memcmp(pkt->data, "\002\000\007_result", 10)) {
switch (rt->state) {
case STATE_HANDSHAKED: case STATE_HANDSHAKED:
if (!rt->is_input) { if (!rt->is_input) {
if ((ret = gen_release_stream(s, rt)) < 0) if ((ret = gen_release_stream(s, rt)) < 0)
...@@ -996,35 +1025,73 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) ...@@ -996,35 +1025,73 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
} }
rt->state = STATE_READY; rt->state = STATE_READY;
break; break;
}
} else if (!memcmp(pkt->data, "\002\000\010onStatus", 11)) {
const uint8_t* ptr = pkt->data + 11;
uint8_t tmpstr[256];
for (i = 0; i < 2; i++) {
t = ff_amf_tag_size(ptr, data_end);
if (t < 0)
return 1;
ptr += t;
}
t = ff_amf_get_field_value(ptr, data_end,
"level", tmpstr, sizeof(tmpstr));
if (!t && !strcmp(tmpstr, "error")) {
if (!ff_amf_get_field_value(ptr, data_end,
"description", tmpstr, sizeof(tmpstr)))
av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr);
return -1;
}
t = ff_amf_get_field_value(ptr, data_end,
"code", tmpstr, sizeof(tmpstr));
if (!t && !strcmp(tmpstr, "NetStream.Play.Start")) rt->state = STATE_PLAYING;
if (!t && !strcmp(tmpstr, "NetStream.Play.Stop")) rt->state = STATE_STOPPED;
if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED;
if (!t && !strcmp(tmpstr, "NetStream.Publish.Start")) rt->state = STATE_PUBLISHING;
} else if (!memcmp(pkt->data, "\002\000\010onBWDone", 11)) {
if ((ret = gen_check_bw(s, rt)) < 0)
return ret;
} }
} else if (!memcmp(pkt->data, "\002\000\010onStatus", 11)) {
const uint8_t* ptr = pkt->data + 11;
uint8_t tmpstr[256];
for (i = 0; i < 2; i++) {
t = ff_amf_tag_size(ptr, data_end);
if (t < 0)
return 1;
ptr += t;
}
t = ff_amf_get_field_value(ptr, data_end,
"level", tmpstr, sizeof(tmpstr));
if (!t && !strcmp(tmpstr, "error")) {
if (!ff_amf_get_field_value(ptr, data_end,
"description", tmpstr, sizeof(tmpstr)))
av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr);
return -1;
}
t = ff_amf_get_field_value(ptr, data_end,
"code", tmpstr, sizeof(tmpstr));
if (!t && !strcmp(tmpstr, "NetStream.Play.Start")) rt->state = STATE_PLAYING;
if (!t && !strcmp(tmpstr, "NetStream.Play.Stop")) rt->state = STATE_STOPPED;
if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED;
if (!t && !strcmp(tmpstr, "NetStream.Publish.Start")) rt->state = STATE_PUBLISHING;
} else if (!memcmp(pkt->data, "\002\000\010onBWDone", 11)) {
if ((ret = gen_check_bw(s, rt)) < 0)
return ret;
}
return 0;
}
/**
* Parse received packet and possibly perform some action depending on
* the packet contents.
* @return 0 for no errors, negative values for serious errors which prevent
* further communications, positive values for uncritical errors
*/
static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
{
int ret;
#ifdef DEBUG
ff_rtmp_packet_dump(s, pkt);
#endif
switch (pkt->type) {
case RTMP_PT_CHUNK_SIZE:
if ((ret = handle_chunk_size(s, pkt)) < 0)
return ret;
break;
case RTMP_PT_PING:
if ((ret = handle_ping(s, pkt)) < 0)
return ret;
break;
case RTMP_PT_CLIENT_BW:
if ((ret = handle_client_bw(s, pkt)) < 0)
return ret;
break;
case RTMP_PT_SERVER_BW:
if ((ret = handle_server_bw(s, pkt)) < 0)
return ret;
break;
case RTMP_PT_INVOKE:
if ((ret = handle_invoke(s, pkt)) < 0)
return ret;
break; break;
case RTMP_PT_VIDEO: case RTMP_PT_VIDEO:
case RTMP_PT_AUDIO: case RTMP_PT_AUDIO:
......
/*
* Simple URL decoding function
* Copyright (c) 2012 Antti Seppälä
*
* References:
* RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
* T. Berners-Lee et al. The Internet Society, 2005
*
* based on http://www.icosaedro.it/apache/urldecode.c
* from Umberto Salsi (salsi@icosaedro.it)
*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <ctype.h>
#include <string.h>
#include "libavutil/mem.h"
#include "libavutil/avstring.h"
#include "urldecode.h"
char *ff_urldecode(const char *url)
{
int s = 0, d = 0, url_len = 0;
char c;
char *dest = NULL;
if (!url)
return NULL;
url_len = strlen(url) + 1;
dest = av_malloc(url_len);
if (!dest)
return NULL;
while (s < url_len) {
c = url[s++];
if (c == '%' && s + 2 < url_len) {
char c2 = url[s++];
char c3 = url[s++];
if (isxdigit(c2) && isxdigit(c3)) {
c2 = av_tolower(c2);
c3 = av_tolower(c3);
if (c2 <= '9')
c2 = c2 - '0';
else
c2 = c2 - 'a' + 10;
if (c3 <= '9')
c3 = c3 - '0';
else
c3 = c3 - 'a' + 10;
dest[d++] = 16 * c2 + c3;
} else { /* %zz or something other invalid */
dest[d++] = c;
dest[d++] = c2;
dest[d++] = c3;
}
} else if (c == '+') {
dest[d++] = ' ';
} else {
dest[d++] = c;
}
}
return dest;
}
/*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVFORMAT_URLDECODE_H
#define AVFORMAT_URLDECODE_H
/**
* Decodes an URL from its percent-encoded form back into normal
* representation. This function returns the decoded URL in a string.
* The URL to be decoded does not necessarily have to be encoded but
* in that case the original string is duplicated.
*
* @param url a string to be decoded.
* @return new string with the URL decoded or NULL if decoding failed.
* Note that the returned string should be explicitly freed when not
* used anymore.
*/
char *ff_urldecode(const char *url);
#endif /* AVFORMAT_URLDECODE_H */
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 54 #define LIBAVFORMAT_VERSION_MAJOR 54
#define LIBAVFORMAT_VERSION_MINOR 20 #define LIBAVFORMAT_VERSION_MINOR 20
#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, \
......
...@@ -175,7 +175,12 @@ cglobal mix_1_to_2_fltp_flt, 3,5,4, src0, matrix0, len, src1, matrix1 ...@@ -175,7 +175,12 @@ cglobal mix_1_to_2_fltp_flt, 3,5,4, src0, matrix0, len, src1, matrix1
add src0q, mmsize add src0q, mmsize
sub lend, mmsize/4 sub lend, mmsize/4
jg .loop jg .loop
%if mmsize == 32
vzeroupper
RET
%else
REP_RET REP_RET
%endif
%endmacro %endmacro
INIT_XMM sse INIT_XMM sse
......
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