mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
Merge remote-tracking branch 'qatar/master'
* qatar/master: fate: Fix fate-ac3-fixed-encode for pre-ssse3 x86 machines http: Pass the proper return code of net IO operations http: Add 'post_data', a new option which sets custom HTTP post data lavfi: amix: check active input count before calling request_samples vp8: move block coeff arithcoder on stack. mp3/ac3 probe: search for PES headers to prevent probing MPEG-PS as MP3. Conflicts: libavformat/ac3dec.c libavformat/mp3dec.c tests/fate/ac3.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
5afdb3e6b1
@ -708,56 +708,58 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_
|
||||
* @return 0 if no coeffs were decoded
|
||||
* otherwise, the index of the last coeff decoded plus one
|
||||
*/
|
||||
static int decode_block_coeffs_internal(VP56RangeCoder *c, DCTELEM block[16],
|
||||
static int decode_block_coeffs_internal(VP56RangeCoder *r, DCTELEM block[16],
|
||||
uint8_t probs[16][3][NUM_DCT_TOKENS-1],
|
||||
int i, uint8_t *token_prob, int16_t qmul[2])
|
||||
{
|
||||
VP56RangeCoder c = *r;
|
||||
goto skip_eob;
|
||||
do {
|
||||
int coeff;
|
||||
if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB
|
||||
return i;
|
||||
if (!vp56_rac_get_prob_branchy(&c, token_prob[0])) // DCT_EOB
|
||||
break;
|
||||
|
||||
skip_eob:
|
||||
if (!vp56_rac_get_prob_branchy(c, token_prob[1])) { // DCT_0
|
||||
if (!vp56_rac_get_prob_branchy(&c, token_prob[1])) { // DCT_0
|
||||
if (++i == 16)
|
||||
return i; // invalid input; blocks should end with EOB
|
||||
break; // invalid input; blocks should end with EOB
|
||||
token_prob = probs[i][0];
|
||||
goto skip_eob;
|
||||
}
|
||||
|
||||
if (!vp56_rac_get_prob_branchy(c, token_prob[2])) { // DCT_1
|
||||
if (!vp56_rac_get_prob_branchy(&c, token_prob[2])) { // DCT_1
|
||||
coeff = 1;
|
||||
token_prob = probs[i+1][1];
|
||||
} else {
|
||||
if (!vp56_rac_get_prob_branchy(c, token_prob[3])) { // DCT 2,3,4
|
||||
coeff = vp56_rac_get_prob_branchy(c, token_prob[4]);
|
||||
if (!vp56_rac_get_prob_branchy(&c, token_prob[3])) { // DCT 2,3,4
|
||||
coeff = vp56_rac_get_prob_branchy(&c, token_prob[4]);
|
||||
if (coeff)
|
||||
coeff += vp56_rac_get_prob(c, token_prob[5]);
|
||||
coeff += vp56_rac_get_prob(&c, token_prob[5]);
|
||||
coeff += 2;
|
||||
} else {
|
||||
// DCT_CAT*
|
||||
if (!vp56_rac_get_prob_branchy(c, token_prob[6])) {
|
||||
if (!vp56_rac_get_prob_branchy(c, token_prob[7])) { // DCT_CAT1
|
||||
coeff = 5 + vp56_rac_get_prob(c, vp8_dct_cat1_prob[0]);
|
||||
if (!vp56_rac_get_prob_branchy(&c, token_prob[6])) {
|
||||
if (!vp56_rac_get_prob_branchy(&c, token_prob[7])) { // DCT_CAT1
|
||||
coeff = 5 + vp56_rac_get_prob(&c, vp8_dct_cat1_prob[0]);
|
||||
} else { // DCT_CAT2
|
||||
coeff = 7;
|
||||
coeff += vp56_rac_get_prob(c, vp8_dct_cat2_prob[0]) << 1;
|
||||
coeff += vp56_rac_get_prob(c, vp8_dct_cat2_prob[1]);
|
||||
coeff += vp56_rac_get_prob(&c, vp8_dct_cat2_prob[0]) << 1;
|
||||
coeff += vp56_rac_get_prob(&c, vp8_dct_cat2_prob[1]);
|
||||
}
|
||||
} else { // DCT_CAT3 and up
|
||||
int a = vp56_rac_get_prob(c, token_prob[8]);
|
||||
int b = vp56_rac_get_prob(c, token_prob[9+a]);
|
||||
int a = vp56_rac_get_prob(&c, token_prob[8]);
|
||||
int b = vp56_rac_get_prob(&c, token_prob[9+a]);
|
||||
int cat = (a<<1) + b;
|
||||
coeff = 3 + (8<<cat);
|
||||
coeff += vp8_rac_get_coeff(c, ff_vp8_dct_cat_prob[cat]);
|
||||
coeff += vp8_rac_get_coeff(&c, ff_vp8_dct_cat_prob[cat]);
|
||||
}
|
||||
}
|
||||
token_prob = probs[i+1][2];
|
||||
}
|
||||
block[zigzag_scan[i]] = (vp8_rac_get(c) ? -coeff : coeff) * qmul[!!i];
|
||||
block[zigzag_scan[i]] = (vp8_rac_get(&c) ? -coeff : coeff) * qmul[!!i];
|
||||
} while (++i < 16);
|
||||
|
||||
*r = c;
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
@ -389,6 +389,10 @@ static int request_frame(AVFilterLink *outlink)
|
||||
int ret;
|
||||
int wanted_samples, available_samples;
|
||||
|
||||
ret = calc_active_inputs(s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (s->input_state[0] == INPUT_OFF) {
|
||||
ret = request_samples(ctx, 1);
|
||||
if (ret < 0)
|
||||
@ -419,6 +423,8 @@ static int request_frame(AVFilterLink *outlink)
|
||||
av_assert0(s->frame_list->nb_frames > 0);
|
||||
|
||||
wanted_samples = frame_list_next_frame_size(s->frame_list);
|
||||
|
||||
if (s->active_inputs > 1) {
|
||||
ret = request_samples(ctx, wanted_samples);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@ -427,7 +433,6 @@ static int request_frame(AVFilterLink *outlink)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (s->active_inputs > 1) {
|
||||
available_samples = get_available_samples(s);
|
||||
if (!available_samples)
|
||||
return 0;
|
||||
|
@ -55,6 +55,8 @@ typedef struct {
|
||||
int end_chunked_post; /**< A flag which indicates if the end of chunked encoding has been sent. */
|
||||
int end_header; /**< A flag which indicates we have finished to read POST reply. */
|
||||
int multiple_requests; /**< A flag which indicates if we use persistent connections. */
|
||||
uint8_t *post_data;
|
||||
int post_datalen;
|
||||
} HTTPContext;
|
||||
|
||||
#define OFFSET(x) offsetof(HTTPContext, x)
|
||||
@ -66,6 +68,7 @@ static const AVOption options[] = {
|
||||
{"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
||||
{"user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC},
|
||||
{"multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, D|E },
|
||||
{"post_data", "custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E },
|
||||
{NULL}
|
||||
};
|
||||
#define HTTP_CLASS(flavor)\
|
||||
@ -227,7 +230,7 @@ static int http_getc(HTTPContext *s)
|
||||
if (s->buf_ptr >= s->buf_end) {
|
||||
len = ffurl_read(s->hd, s->buffer, BUFFER_SIZE);
|
||||
if (len < 0) {
|
||||
return AVERROR(EIO);
|
||||
return len;
|
||||
} else if (len == 0) {
|
||||
return -1;
|
||||
} else {
|
||||
@ -247,7 +250,7 @@ static int http_get_line(HTTPContext *s, char *line, int line_size)
|
||||
for(;;) {
|
||||
ch = http_getc(s);
|
||||
if (ch < 0)
|
||||
return AVERROR(EIO);
|
||||
return ch;
|
||||
if (ch == '\n') {
|
||||
/* process line */
|
||||
if (q > line && q[-1] == '\r')
|
||||
@ -354,8 +357,8 @@ static int http_read_header(URLContext *h, int *new_location)
|
||||
int err = 0;
|
||||
|
||||
for (;;) {
|
||||
if (http_get_line(s, line, sizeof(line)) < 0)
|
||||
return AVERROR(EIO);
|
||||
if ((err = http_get_line(s, line, sizeof(line))) < 0)
|
||||
return err;
|
||||
|
||||
av_dlog(NULL, "header='%s'\n", line);
|
||||
|
||||
@ -385,6 +388,14 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
||||
|
||||
/* send http header */
|
||||
post = h->flags & AVIO_FLAG_WRITE;
|
||||
|
||||
if (s->post_data) {
|
||||
/* force POST method and disable chunked encoding when
|
||||
* custom HTTP post data is set */
|
||||
post = 1;
|
||||
s->chunked_post = 0;
|
||||
}
|
||||
|
||||
method = post ? "POST" : "GET";
|
||||
authstr = ff_http_auth_create_response(&s->auth_state, auth, local_path,
|
||||
method);
|
||||
@ -416,6 +427,9 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
||||
if (!has_header(s->headers, "\r\nHost: "))
|
||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||
"Host: %s\r\n", hoststr);
|
||||
if (!has_header(s->headers, "\r\nContent-Length: ") && s->post_data)
|
||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||
"Content-Length: %d\r\n", s->post_datalen);
|
||||
|
||||
/* now add in custom headers */
|
||||
if (s->headers)
|
||||
@ -437,8 +451,12 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
||||
|
||||
av_freep(&authstr);
|
||||
av_freep(&proxyauthstr);
|
||||
if (ffurl_write(s->hd, s->buffer, strlen(s->buffer)) < 0)
|
||||
return AVERROR(EIO);
|
||||
if ((err = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0)
|
||||
return err;
|
||||
|
||||
if (s->post_data)
|
||||
if ((err = ffurl_write(s->hd, s->post_data, s->post_datalen)) < 0)
|
||||
return err;
|
||||
|
||||
/* init input buffer */
|
||||
s->buf_ptr = s->buffer;
|
||||
@ -449,7 +467,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
||||
s->willclose = 0;
|
||||
s->end_chunked_post = 0;
|
||||
s->end_header = 0;
|
||||
if (post) {
|
||||
if (post && !s->post_data) {
|
||||
/* Pretend that it did work. We didn't read any header yet, since
|
||||
* we've still to send the POST data, but the code calling this
|
||||
* function will check http_code after we return. */
|
||||
@ -512,8 +530,8 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
|
||||
|
||||
for(;;) {
|
||||
do {
|
||||
if (http_get_line(s, line, sizeof(line)) < 0)
|
||||
return AVERROR(EIO);
|
||||
if ((err = http_get_line(s, line, sizeof(line))) < 0)
|
||||
return err;
|
||||
} while (!*line); /* skip CR LF from last chunk */
|
||||
|
||||
s->chunksize = strtoll(line, NULL, 16);
|
||||
|
Loading…
Reference in New Issue
Block a user