Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b4552cc9b8 | ||
![]() |
172f929767 | ||
![]() |
66a9edfcf6 | ||
![]() |
a9382fc15c | ||
![]() |
bd9dcb411d | ||
![]() |
ae81a0e32d | ||
![]() |
4f93400db1 | ||
![]() |
0cd61c7f7d | ||
![]() |
28ac4e91dc | ||
![]() |
6b683be641 | ||
![]() |
3a3b5ae4c0 | ||
![]() |
70fcea3b77 | ||
![]() |
b545d11d49 | ||
![]() |
4324d7bade | ||
![]() |
c88bdac460 | ||
![]() |
bdf6e6fff4 | ||
![]() |
83e4aa3e7c | ||
![]() |
fce2cfbdcf | ||
![]() |
72f1907c96 | ||
![]() |
074ebfacf4 | ||
![]() |
47f8497837 | ||
![]() |
93f26b7992 | ||
![]() |
f684bbf224 | ||
![]() |
edca16f1af | ||
![]() |
aeac212fda | ||
![]() |
62f05d6309 | ||
![]() |
bd339d4882 | ||
![]() |
9de71b0eb2 | ||
![]() |
7e73760950 | ||
![]() |
0639e403be | ||
![]() |
5c7d6be5f9 | ||
![]() |
2005887707 | ||
![]() |
cf8462ce00 | ||
![]() |
02c8c064ea | ||
![]() |
9a4acedf31 | ||
![]() |
c2d37e7364 | ||
![]() |
62baf22ec0 | ||
![]() |
8f7d839e15 | ||
![]() |
93716f7bea | ||
![]() |
ff4c53e8b3 | ||
![]() |
9a22d6dd63 | ||
![]() |
beb28bc55d | ||
![]() |
1fa7ad2e20 | ||
![]() |
f514834917 | ||
![]() |
1d0e583728 | ||
![]() |
782331be1e | ||
![]() |
94c7ee4d9e | ||
![]() |
b7154758de | ||
![]() |
cd7d575e90 | ||
![]() |
17d169ce0f | ||
![]() |
fb1fb462e5 | ||
![]() |
7da810e68b | ||
![]() |
6de6d9e2d3 | ||
![]() |
736851264b | ||
![]() |
59431fc841 | ||
![]() |
f581e25a69 |
4
configure
vendored
4
configure
vendored
@@ -2801,7 +2801,9 @@ probe_cc(){
|
||||
unset _depflags _DEPCMD _DEPFLAGS
|
||||
_flags_filter=echo
|
||||
|
||||
if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
|
||||
if $_cc --version 2>&1 | grep -q '^GNU assembler'; then
|
||||
true # no-op to avoid reading stdin in following checks
|
||||
elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
|
||||
_type=llvm_gcc
|
||||
gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
|
||||
_ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
|
||||
|
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 2.0.2
|
||||
PROJECT_NUMBER = 2.0.3
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify an logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
@@ -103,8 +103,8 @@ endif
|
||||
uninstall: uninstall-man
|
||||
|
||||
uninstall-man:
|
||||
$(RM) $(addprefix "$(MANDIR)/man1/",$(MANPAGES1))
|
||||
$(RM) $(addprefix "$(MANDIR)/man3/",$(MANPAGES3))
|
||||
$(RM) $(addprefix "$(MANDIR)/man1/",$(PROGS-yes:%=%.1) $(PROGS-yes:%=%-all.1) $(COMPONENTS-yes:%=%.1))
|
||||
$(RM) $(addprefix "$(MANDIR)/man3/",$(LIBRARIES-yes:%=%.3))
|
||||
|
||||
clean:: docclean
|
||||
|
||||
|
@@ -753,7 +753,7 @@ Set maximum frame size, or duration of a frame in milliseconds. The
|
||||
argument must be exactly the following: 2.5, 5, 10, 20, 40, 60. Smaller
|
||||
frame sizes achieve lower latency but less quality at a given bitrate.
|
||||
Sizes greater than 20ms are only interesting at fairly low bitrates.
|
||||
The default of FFmpeg is 10ms, but is 20ms in @command{opusenc}.
|
||||
The default is 20ms.
|
||||
|
||||
@item packet_loss (@emph{expect-loss})
|
||||
Set expected packet loss percentage. The default is 0.
|
||||
|
@@ -92,6 +92,11 @@ void choose_sample_fmt(AVStream *st, AVCodec *codec)
|
||||
|
||||
static char *choose_pix_fmts(OutputStream *ost)
|
||||
{
|
||||
AVDictionaryEntry *strict_dict = av_dict_get(ost->opts, "strict", NULL, 0);
|
||||
if (strict_dict)
|
||||
// used by choose_pixel_fmt() and below
|
||||
av_opt_set(ost->st->codec, "strict", strict_dict->value, 0);
|
||||
|
||||
if (ost->keep_pix_fmt) {
|
||||
if (ost->filter)
|
||||
avfilter_graph_set_auto_convert(ost->filter->graph->graph,
|
||||
|
@@ -328,6 +328,14 @@ static AVLFG random_state;
|
||||
|
||||
static FILE *logfile = NULL;
|
||||
|
||||
static void htmlstrip(char *s) {
|
||||
while (s && *s) {
|
||||
s += strspn(s, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,. ");
|
||||
if (*s)
|
||||
*s++ = '?';
|
||||
}
|
||||
}
|
||||
|
||||
static int64_t ffm_read_write_index(int fd)
|
||||
{
|
||||
uint8_t buf[8];
|
||||
@@ -1887,6 +1895,7 @@ static int http_parse_request(HTTPContext *c)
|
||||
send_error:
|
||||
c->http_error = 404;
|
||||
q = c->buffer;
|
||||
htmlstrip(msg);
|
||||
snprintf(q, c->buffer_size,
|
||||
"HTTP/1.0 404 Not Found\r\n"
|
||||
"Content-type: text/html\r\n"
|
||||
|
@@ -41,10 +41,10 @@ function ff_scalarproduct_int16_neon, export=1
|
||||
|
||||
vpadd.s32 d16, d0, d1
|
||||
vpadd.s32 d17, d2, d3
|
||||
vpadd.s32 d10, d4, d5
|
||||
vpadd.s32 d11, d6, d7
|
||||
vpadd.s32 d18, d4, d5
|
||||
vpadd.s32 d19, d6, d7
|
||||
vpadd.s32 d0, d16, d17
|
||||
vpadd.s32 d1, d10, d11
|
||||
vpadd.s32 d1, d18, d19
|
||||
vpadd.s32 d2, d0, d1
|
||||
vpaddl.s32 d3, d2
|
||||
vmov.32 r0, d3[0]
|
||||
@@ -81,10 +81,10 @@ function ff_scalarproduct_and_madd_int16_neon, export=1
|
||||
|
||||
vpadd.s32 d16, d0, d1
|
||||
vpadd.s32 d17, d2, d3
|
||||
vpadd.s32 d10, d4, d5
|
||||
vpadd.s32 d11, d6, d7
|
||||
vpadd.s32 d18, d4, d5
|
||||
vpadd.s32 d19, d6, d7
|
||||
vpadd.s32 d0, d16, d17
|
||||
vpadd.s32 d1, d10, d11
|
||||
vpadd.s32 d1, d18, d19
|
||||
vpadd.s32 d2, d0, d1
|
||||
vpaddl.s32 d3, d2
|
||||
vmov.32 r0, d3[0]
|
||||
|
@@ -356,7 +356,7 @@ int av_packet_merge_side_data(AVPacket *pkt){
|
||||
int av_packet_split_side_data(AVPacket *pkt){
|
||||
if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
|
||||
int i;
|
||||
unsigned int size, orig_pktsize = pkt->size;
|
||||
unsigned int size;
|
||||
uint8_t *p;
|
||||
|
||||
p = pkt->data + pkt->size - 8 - 5;
|
||||
@@ -377,7 +377,7 @@ int av_packet_split_side_data(AVPacket *pkt){
|
||||
for (i=0; ; i++){
|
||||
size= AV_RB32(p);
|
||||
av_assert0(size<=INT_MAX && p - pkt->data >= size);
|
||||
pkt->side_data[i].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
pkt->side_data[i].data = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
pkt->side_data[i].size = size;
|
||||
pkt->side_data[i].type = p[4]&127;
|
||||
if (!pkt->side_data[i].data)
|
||||
@@ -389,13 +389,6 @@ int av_packet_split_side_data(AVPacket *pkt){
|
||||
p-= size+5;
|
||||
}
|
||||
pkt->size -= 8;
|
||||
/* FFMIN() prevents overflow in case the packet wasn't allocated with
|
||||
* proper padding.
|
||||
* If the side data is smaller than the buffer padding size, the
|
||||
* remaining bytes should have already been filled with zeros by the
|
||||
* original packet allocation anyway. */
|
||||
memset(pkt->data + pkt->size, 0,
|
||||
FFMIN(orig_pktsize - pkt->size, FF_INPUT_BUFFER_PADDING_SIZE));
|
||||
pkt->side_data_elems = i+1;
|
||||
return 1;
|
||||
}
|
||||
|
@@ -120,6 +120,7 @@ typedef struct BinkContext {
|
||||
int version; ///< internal Bink file version
|
||||
int has_alpha;
|
||||
int swap_planes;
|
||||
unsigned frame_num;
|
||||
|
||||
Bundle bundle[BINKB_NB_SRC]; ///< bundles for decoding all data types
|
||||
Tree col_high[16]; ///< trees for decoding high nibble in "colours" data type
|
||||
@@ -1206,6 +1207,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
if (c->version >= 'i')
|
||||
skip_bits_long(&gb, 32);
|
||||
|
||||
c->frame_num++;
|
||||
|
||||
for (plane = 0; plane < 3; plane++) {
|
||||
plane_idx = (!plane || !c->swap_planes) ? plane : (plane ^ 3);
|
||||
|
||||
@@ -1214,7 +1217,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
return ret;
|
||||
} else {
|
||||
if ((ret = binkb_decode_plane(c, frame, &gb, plane_idx,
|
||||
!avctx->frame_number, !!plane)) < 0)
|
||||
c->frame_num == 1, !!plane)) < 0)
|
||||
return ret;
|
||||
}
|
||||
if (get_bits_count(&gb) >= bits_count)
|
||||
@@ -1332,6 +1335,13 @@ static av_cold int decode_end(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void flush(AVCodecContext *avctx)
|
||||
{
|
||||
BinkContext * const c = avctx->priv_data;
|
||||
|
||||
c->frame_num = 0;
|
||||
}
|
||||
|
||||
AVCodec ff_bink_decoder = {
|
||||
.name = "binkvideo",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
@@ -1341,5 +1351,6 @@ AVCodec ff_bink_decoder = {
|
||||
.close = decode_end,
|
||||
.decode = decode_frame,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Bink video"),
|
||||
.flush = flush,
|
||||
.capabilities = CODEC_CAP_DR1,
|
||||
};
|
||||
|
@@ -306,7 +306,7 @@ STOP_TIMER("get_cabac_bypass")
|
||||
|
||||
for(i=0; i<SIZE; i++){
|
||||
START_TIMER
|
||||
if( (r[i]&1) != get_cabac(&c, state) )
|
||||
if( (r[i]&1) != get_cabac_noinline(&c, state) )
|
||||
av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i);
|
||||
STOP_TIMER("get_cabac")
|
||||
}
|
||||
|
@@ -762,6 +762,17 @@ void ff_er_frame_start(ERContext *s)
|
||||
s->error_occurred = 0;
|
||||
}
|
||||
|
||||
static int er_supported(ERContext *s)
|
||||
{
|
||||
if(s->avctx->hwaccel ||
|
||||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
|
||||
!s->cur_pic ||
|
||||
s->cur_pic->field_picture
|
||||
)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a slice.
|
||||
* @param endx x component of the last macroblock, can be -1
|
||||
@@ -828,7 +839,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
|
||||
s->error_status_table[start_xy] |= VP_START;
|
||||
|
||||
if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&
|
||||
s->avctx->skip_top * s->mb_width < start_i) {
|
||||
er_supported(s) && s->avctx->skip_top * s->mb_width < start_i) {
|
||||
int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];
|
||||
|
||||
prev_status &= ~ VP_START;
|
||||
@@ -853,9 +864,7 @@ void ff_er_frame_end(ERContext *s)
|
||||
* though it should not crash if enabled. */
|
||||
if (!s->avctx->err_recognition || s->error_count == 0 ||
|
||||
s->avctx->lowres ||
|
||||
s->avctx->hwaccel ||
|
||||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
|
||||
!s->cur_pic || s->cur_pic->field_picture ||
|
||||
!er_supported(s) ||
|
||||
s->error_count == 3 * s->mb_width *
|
||||
(s->avctx->skip_top + s->avctx->skip_bottom)) {
|
||||
return;
|
||||
|
@@ -2660,6 +2660,7 @@ static void flush_change(H264Context *h)
|
||||
h->sync= 0;
|
||||
h->list_count = 0;
|
||||
h->current_slice = 0;
|
||||
h->mmco_reset = 1;
|
||||
}
|
||||
|
||||
/* forget old pics after a seek */
|
||||
@@ -3434,7 +3435,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
} else {
|
||||
/* Shorten frame num gaps so we don't have to allocate reference
|
||||
* frames just to throw them away */
|
||||
if (h->frame_num != h->prev_frame_num && h->prev_frame_num >= 0) {
|
||||
if (h->frame_num != h->prev_frame_num) {
|
||||
int unwrap_prev_frame_num = h->prev_frame_num;
|
||||
int max_frame_num = 1 << h->sps.log2_max_frame_num;
|
||||
|
||||
@@ -3461,7 +3462,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
|
||||
|
||||
/* Mark old field/frame as completed */
|
||||
if (!last_pic_droppable && h0->cur_pic_ptr->tf.owner == h0->avctx) {
|
||||
if (h0->cur_pic_ptr->tf.owner == h0->avctx) {
|
||||
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
|
||||
last_pic_structure == PICT_BOTTOM_FIELD);
|
||||
}
|
||||
@@ -3470,7 +3471,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
|
||||
/* Previous field is unmatched. Don't display it, but let it
|
||||
* remain for reference if marked as such. */
|
||||
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
|
||||
if (last_pic_structure != PICT_FRAME) {
|
||||
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
|
||||
last_pic_structure == PICT_TOP_FIELD);
|
||||
}
|
||||
@@ -3480,7 +3481,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
* different frame_nums. Consider this field first in
|
||||
* pair. Throw away previous field except for reference
|
||||
* purposes. */
|
||||
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
|
||||
if (last_pic_structure != PICT_FRAME) {
|
||||
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
|
||||
last_pic_structure == PICT_TOP_FIELD);
|
||||
}
|
||||
@@ -3507,7 +3508,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
}
|
||||
}
|
||||
|
||||
while (h->frame_num != h->prev_frame_num && h->prev_frame_num >= 0 && !h0->first_field &&
|
||||
while (h->frame_num != h->prev_frame_num && !h0->first_field &&
|
||||
h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
|
||||
Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
|
||||
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
|
||||
|
@@ -583,7 +583,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
|
||||
if (mmco[i].opcode != MMCO_SHORT2LONG ||
|
||||
!h->long_ref[mmco[i].long_arg] ||
|
||||
h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
|
||||
av_log(h->avctx, AV_LOG_ERROR, "mmco: unref short failure\n");
|
||||
av_log(h->avctx, h->short_ref_count ? AV_LOG_ERROR : AV_LOG_DEBUG, "mmco: unref short failure\n");
|
||||
err = AVERROR_INVALIDDATA;
|
||||
}
|
||||
continue;
|
||||
@@ -733,7 +733,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
|
||||
print_short_term(h);
|
||||
print_long_term(h);
|
||||
|
||||
if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 + (h->picture_structure != PICT_FRAME) && h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
|
||||
if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) && h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
|
||||
h->cur_pic_ptr->sync |= 1;
|
||||
if(!h->avctx->has_b_frames)
|
||||
h->sync = 2;
|
||||
|
@@ -243,6 +243,11 @@ static int get_siz(Jpeg2000DecoderContext *s)
|
||||
s->tile_offset_y = bytestream2_get_be32u(&s->g); // YT0Siz
|
||||
ncomponents = bytestream2_get_be16u(&s->g); // CSiz
|
||||
|
||||
if (s->image_offset_x || s->image_offset_y) {
|
||||
avpriv_request_sample(s->avctx, "Support for image offsets");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if (ncomponents <= 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid number of components: %d\n",
|
||||
s->ncomponents);
|
||||
@@ -369,11 +374,18 @@ static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (c->nreslevels <= s->reduction_factor) {
|
||||
/* we are forced to update reduction_factor as its requested value is
|
||||
not compatible with this bitstream, and as we might have used it
|
||||
already in setup earlier we have to fail this frame until
|
||||
reinitialization is implemented */
|
||||
av_log(s->avctx, AV_LOG_ERROR, "reduction_factor too large for this bitstream, max is %d\n", c->nreslevels - 1);
|
||||
s->reduction_factor = c->nreslevels - 1;
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
/* compute number of resolution levels to decode */
|
||||
if (c->nreslevels < s->reduction_factor)
|
||||
c->nreslevels2decode = 1;
|
||||
else
|
||||
c->nreslevels2decode = c->nreslevels - s->reduction_factor;
|
||||
c->nreslevels2decode = c->nreslevels - s->reduction_factor;
|
||||
|
||||
c->log2_cblk_width = (bytestream2_get_byteu(&s->g) & 15) + 2; // cblk width
|
||||
c->log2_cblk_height = (bytestream2_get_byteu(&s->g) & 15) + 2; // cblk height
|
||||
@@ -872,6 +884,10 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
|
||||
prcx = ff_jpeg2000_ceildivpow2(x, reducedresno) >> rlevel->log2_prec_width;
|
||||
prcy = ff_jpeg2000_ceildivpow2(y, reducedresno) >> rlevel->log2_prec_height;
|
||||
precno = prcx + rlevel->num_precincts_x * prcy;
|
||||
|
||||
if (prcx >= rlevel->num_precincts_x || prcy >= rlevel->num_precincts_y)
|
||||
return AVERROR_PATCHWELCOME;
|
||||
|
||||
for (layno = 0; layno < tile->codsty[0].nlayers; layno++) {
|
||||
if ((ret = jpeg2000_decode_packet(s, codsty, rlevel,
|
||||
precno, layno,
|
||||
@@ -1135,6 +1151,12 @@ static void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
|
||||
int32_t *src[3], i0, i1, i2;
|
||||
float *srcf[3], i0f, i1f, i2f;
|
||||
|
||||
for (i = 1; i < 3; i++)
|
||||
if (tile->codsty[0].transform != tile->codsty[i].transform) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Transforms mismatch, MCT not supported\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (tile->codsty[0].transform == FF_DWT97)
|
||||
srcf[i] = tile->comp[i].f_data;
|
||||
@@ -1267,12 +1289,12 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
|
||||
|
||||
|
||||
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
|
||||
line = picture->data[plane] + y * picture->linesize[plane];
|
||||
line = picture->data[plane] + y / s->cdy[compno] * picture->linesize[plane];
|
||||
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
|
||||
uint8_t *dst;
|
||||
|
||||
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
|
||||
dst = line + x * pixelsize + compno*!planar;
|
||||
dst = line + x / s->cdx[compno] * pixelsize + compno*!planar;
|
||||
|
||||
if (codsty->transform == FF_DWT97) {
|
||||
for (; x < w; x += s->cdx[compno]) {
|
||||
@@ -1313,12 +1335,12 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
|
||||
plane = s->cdef[compno] ? s->cdef[compno]-1 : (s->ncomponents-1);
|
||||
|
||||
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
|
||||
linel = (uint16_t *)picture->data[plane] + y * (picture->linesize[plane] >> 1);
|
||||
linel = (uint16_t *)picture->data[plane] + y / s->cdy[compno] * (picture->linesize[plane] >> 1);
|
||||
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
|
||||
uint16_t *dst;
|
||||
|
||||
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
|
||||
dst = linel + (x * pixelsize + compno*!planar);
|
||||
dst = linel + (x / s->cdx[compno] * pixelsize + compno*!planar);
|
||||
if (codsty->transform == FF_DWT97) {
|
||||
for (; x < w; x += s-> cdx[compno]) {
|
||||
int val = lrintf(*datap) + (1 << (cbps - 1));
|
||||
|
@@ -148,6 +148,8 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state,
|
||||
ret = ret >> 1;
|
||||
}
|
||||
|
||||
if(FFABS(ret) > 0xFFFF)
|
||||
return -0x10000;
|
||||
/* update state */
|
||||
state->A[Q] += FFABS(ret) - RItype;
|
||||
ret *= state->twonear;
|
||||
|
@@ -380,7 +380,7 @@ static const AVOption libopus_options[] = {
|
||||
{ "voip", "Favor improved speech intelligibility", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_VOIP }, 0, 0, FLAGS, "application" },
|
||||
{ "audio", "Favor faithfulness to the input", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_AUDIO }, 0, 0, FLAGS, "application" },
|
||||
{ "lowdelay", "Restrict to only the lowest delay modes", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_RESTRICTED_LOWDELAY }, 0, 0, FLAGS, "application" },
|
||||
{ "frame_duration", "Duration of a frame in milliseconds", OFFSET(frame_duration), AV_OPT_TYPE_FLOAT, { .dbl = 10.0 }, 2.5, 60.0, FLAGS },
|
||||
{ "frame_duration", "Duration of a frame in milliseconds", OFFSET(frame_duration), AV_OPT_TYPE_FLOAT, { .dbl = 20.0 }, 2.5, 60.0, FLAGS },
|
||||
{ "packet_loss", "Expected packet loss percentage", OFFSET(packet_loss), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, FLAGS },
|
||||
{ "vbr", "Variable bit rate mode", OFFSET(vbr), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 2, FLAGS, "vbr" },
|
||||
{ "off", "Use constant bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "vbr" },
|
||||
|
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/lls.h"
|
||||
#include "libavutil/lls2.h"
|
||||
|
||||
#define LPC_USE_DOUBLE
|
||||
#include "lpc.h"
|
||||
@@ -208,7 +208,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
|
||||
}
|
||||
|
||||
if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
|
||||
LLSModel m[2];
|
||||
LLSModel2 m[2];
|
||||
LOCAL_ALIGNED(32, double, var, [FFALIGN(MAX_LPC_ORDER+1,4)]);
|
||||
double av_uninit(weight);
|
||||
memset(var, 0, FFALIGN(MAX_LPC_ORDER+1,4)*sizeof(*var));
|
||||
@@ -217,7 +217,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
|
||||
m[0].coeff[max_order-1][j] = -lpc[max_order-1][j];
|
||||
|
||||
for(; pass<lpc_passes; pass++){
|
||||
avpriv_init_lls(&m[pass&1], max_order);
|
||||
avpriv_init_lls2(&m[pass&1], max_order);
|
||||
|
||||
weight=0;
|
||||
for(i=max_order; i<blocksize; i++){
|
||||
@@ -238,7 +238,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
|
||||
|
||||
m[pass&1].update_lls(&m[pass&1], var);
|
||||
}
|
||||
avpriv_solve_lls(&m[pass&1], 0.001, 0);
|
||||
avpriv_solve_lls2(&m[pass&1], 0.001, 0);
|
||||
}
|
||||
|
||||
for(i=0; i<max_order; i++){
|
||||
|
@@ -2038,7 +2038,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
|
||||
if (s->codec_tag == AV_RL32("BW10")) {
|
||||
s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
|
||||
} else {
|
||||
exchange_uv(s); // common init reset pblocks, so we swap them here
|
||||
s->swap_uv = 1; // in case of xvmc we need to swap uv for each MB
|
||||
s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
|
||||
}
|
||||
|
@@ -537,6 +537,15 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void exchange_uv(MpegEncContext *s)
|
||||
{
|
||||
int16_t (*tmp)[64];
|
||||
|
||||
tmp = s->pblocks[4];
|
||||
s->pblocks[4] = s->pblocks[5];
|
||||
s->pblocks[5] = tmp;
|
||||
}
|
||||
|
||||
static int init_duplicate_context(MpegEncContext *s)
|
||||
{
|
||||
int y_size = s->b8_stride * (2 * s->mb_height + 1);
|
||||
@@ -567,6 +576,8 @@ static int init_duplicate_context(MpegEncContext *s)
|
||||
for (i = 0; i < 12; i++) {
|
||||
s->pblocks[i] = &s->block[i];
|
||||
}
|
||||
if (s->avctx->codec_tag == AV_RL32("VCR2"))
|
||||
exchange_uv(s);
|
||||
|
||||
if (s->out_format == FMT_H263) {
|
||||
/* ac values */
|
||||
@@ -641,6 +652,8 @@ int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src)
|
||||
for (i = 0; i < 12; i++) {
|
||||
dst->pblocks[i] = &dst->block[i];
|
||||
}
|
||||
if (dst->avctx->codec_tag == AV_RL32("VCR2"))
|
||||
exchange_uv(dst);
|
||||
if (!dst->edge_emu_buffer &&
|
||||
(ret = ff_mpv_frame_size_alloc(dst, dst->linesize)) < 0) {
|
||||
av_log(dst->avctx, AV_LOG_ERROR, "failed to allocate context "
|
||||
|
@@ -163,7 +163,8 @@ av_cold void avcodec_register(AVCodec *codec)
|
||||
avcodec_init();
|
||||
p = &first_avcodec;
|
||||
codec->next = NULL;
|
||||
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
|
||||
|
||||
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
|
||||
p = &(*p)->next;
|
||||
|
||||
if (codec->init_static_data)
|
||||
@@ -1899,10 +1900,17 @@ static int add_metadata_from_side_data(AVCodecContext *avctx, AVFrame *frame)
|
||||
if (!side_metadata)
|
||||
goto end;
|
||||
end = side_metadata + size;
|
||||
if (size && end[-1])
|
||||
return AVERROR_INVALIDDATA;
|
||||
while (side_metadata < end) {
|
||||
const uint8_t *key = side_metadata;
|
||||
const uint8_t *val = side_metadata + strlen(key) + 1;
|
||||
int ret = av_dict_set(avpriv_frame_get_metadatap(frame), key, val, 0);
|
||||
int ret;
|
||||
|
||||
if (val >= end)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
ret = av_dict_set(avpriv_frame_get_metadatap(frame), key, val, 0);
|
||||
if (ret < 0)
|
||||
break;
|
||||
side_metadata = val + strlen(val) + 1;
|
||||
@@ -2271,6 +2279,16 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
|
||||
int did_split = av_packet_split_side_data(&tmp);
|
||||
//apply_param_change(avctx, &tmp);
|
||||
|
||||
if (did_split) {
|
||||
/* FFMIN() prevents overflow in case the packet wasn't allocated with
|
||||
* proper padding.
|
||||
* If the side data is smaller than the buffer padding size, the
|
||||
* remaining bytes should have already been filled with zeros by the
|
||||
* original packet allocation anyway. */
|
||||
memset(tmp.data + tmp.size, 0,
|
||||
FFMIN(avpkt->size - tmp.size, FF_INPUT_BUFFER_PADDING_SIZE));
|
||||
}
|
||||
|
||||
pkt_recoded = tmp;
|
||||
ret = recode_subtitle(avctx, &pkt_recoded, &tmp);
|
||||
if (ret < 0) {
|
||||
@@ -2996,7 +3014,7 @@ void av_register_hwaccel(AVHWAccel *hwaccel)
|
||||
{
|
||||
AVHWAccel **p = &first_hwaccel;
|
||||
hwaccel->next = NULL;
|
||||
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
|
||||
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
|
||||
p = &(*p)->next;
|
||||
}
|
||||
|
||||
|
@@ -621,6 +621,10 @@ static void rotate_luts(VC1Context *v)
|
||||
INIT_LUT(32, 0, v->curr_luty[0], v->curr_lutuv[0], 0);
|
||||
INIT_LUT(32, 0, v->curr_luty[1], v->curr_lutuv[1], 0);
|
||||
v->curr_use_ic = 0;
|
||||
if (v->curr_luty == v->next_luty) {
|
||||
// If we just initialized next_lut, clear next_use_ic to match.
|
||||
v->next_use_ic = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
|
||||
|
@@ -248,6 +248,10 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
|
||||
ret = av_opt_set_int_list(sink, "sample_fmts", sample_fmts, AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
ret = av_opt_set_int(sink, "all_channel_counts", 1,
|
||||
AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
}
|
||||
|
||||
lavfi->sinks[i] = sink;
|
||||
|
@@ -685,6 +685,10 @@ static int v4l2_set_parameters(AVFormatContext *s1)
|
||||
standard.index = i;
|
||||
if (v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) {
|
||||
ret = AVERROR(errno);
|
||||
if (ret == AVERROR(EINVAL)) {
|
||||
tpf = &streamparm.parm.capture.timeperframe;
|
||||
break;
|
||||
}
|
||||
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMSTD): %s\n", av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ static av_cold int init(AVFilterContext *ctx)
|
||||
(ret = ff_parse_sample_format(&aconvert->out_sample_fmt, aconvert->format_str, ctx)) < 0)
|
||||
return ret;
|
||||
if (aconvert->channel_layout_str && strcmp(aconvert->channel_layout_str, "auto"))
|
||||
return ff_parse_channel_layout(&aconvert->out_chlayout, aconvert->channel_layout_str, ctx);
|
||||
return ff_parse_channel_layout(&aconvert->out_chlayout, NULL, aconvert->channel_layout_str, ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,6 @@ typedef struct PanContext {
|
||||
double gain[MAX_CHANNELS][MAX_CHANNELS];
|
||||
int64_t need_renorm;
|
||||
int need_renumber;
|
||||
int nb_input_channels;
|
||||
int nb_output_channels;
|
||||
|
||||
int pure_gains;
|
||||
@@ -116,10 +115,10 @@ static av_cold int init(AVFilterContext *ctx)
|
||||
if (!args)
|
||||
return AVERROR(ENOMEM);
|
||||
arg = av_strtok(args, "|", &tokenizer);
|
||||
ret = ff_parse_channel_layout(&pan->out_channel_layout, arg, ctx);
|
||||
ret = ff_parse_channel_layout(&pan->out_channel_layout,
|
||||
&pan->nb_output_channels, arg, ctx);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
pan->nb_output_channels = av_get_channel_layout_nb_channels(pan->out_channel_layout);
|
||||
|
||||
/* parse channel specifications */
|
||||
while ((arg = arg0 = av_strtok(NULL, "|", &tokenizer))) {
|
||||
@@ -239,12 +238,14 @@ static int query_formats(AVFilterContext *ctx)
|
||||
ff_set_common_samplerates(ctx, formats);
|
||||
|
||||
// inlink supports any channel layout
|
||||
layouts = ff_all_channel_layouts();
|
||||
layouts = ff_all_channel_counts();
|
||||
ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts);
|
||||
|
||||
// outlink supports only requested output channel layout
|
||||
layouts = NULL;
|
||||
ff_add_channel_layout(&layouts, pan->out_channel_layout);
|
||||
ff_add_channel_layout(&layouts,
|
||||
pan->out_channel_layout ? pan->out_channel_layout :
|
||||
FF_COUNT2LAYOUT(pan->nb_output_channels));
|
||||
ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts);
|
||||
return 0;
|
||||
}
|
||||
@@ -257,7 +258,6 @@ static int config_props(AVFilterLink *link)
|
||||
int i, j, k, r;
|
||||
double t;
|
||||
|
||||
pan->nb_input_channels = av_get_channel_layout_nb_channels(link->channel_layout);
|
||||
if (pan->need_renumber) {
|
||||
// input channels were given by their name: renumber them
|
||||
for (i = j = 0; i < MAX_CHANNELS; i++) {
|
||||
@@ -271,7 +271,7 @@ static int config_props(AVFilterLink *link)
|
||||
|
||||
// sanity check; can't be done in query_formats since the inlink
|
||||
// channel layout is unknown at that time
|
||||
if (pan->nb_input_channels > SWR_CH_MAX ||
|
||||
if (link->channels > SWR_CH_MAX ||
|
||||
pan->nb_output_channels > SWR_CH_MAX) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"libswresample support a maximum of %d channels. "
|
||||
@@ -286,6 +286,10 @@ static int config_props(AVFilterLink *link)
|
||||
0, ctx);
|
||||
if (!pan->swr)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!link->channel_layout)
|
||||
av_opt_set_int(pan->swr, "ich", link->channels, 0);
|
||||
if (!pan->out_channel_layout)
|
||||
av_opt_set_int(pan->swr, "och", pan->nb_output_channels, 0);
|
||||
|
||||
// gains are pure, init the channel mapping
|
||||
if (pan->pure_gains) {
|
||||
@@ -293,7 +297,7 @@ static int config_props(AVFilterLink *link)
|
||||
// get channel map from the pure gains
|
||||
for (i = 0; i < pan->nb_output_channels; i++) {
|
||||
int ch_id = -1;
|
||||
for (j = 0; j < pan->nb_input_channels; j++) {
|
||||
for (j = 0; j < link->channels; j++) {
|
||||
if (pan->gain[i][j]) {
|
||||
ch_id = j;
|
||||
break;
|
||||
@@ -311,7 +315,7 @@ static int config_props(AVFilterLink *link)
|
||||
if (!((pan->need_renorm >> i) & 1))
|
||||
continue;
|
||||
t = 0;
|
||||
for (j = 0; j < pan->nb_input_channels; j++)
|
||||
for (j = 0; j < link->channels; j++)
|
||||
t += pan->gain[i][j];
|
||||
if (t > -1E-5 && t < 1E-5) {
|
||||
// t is almost 0 but not exactly, this is probably a mistake
|
||||
@@ -320,7 +324,7 @@ static int config_props(AVFilterLink *link)
|
||||
"Degenerate coefficients while renormalizing\n");
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < pan->nb_input_channels; j++)
|
||||
for (j = 0; j < link->channels; j++)
|
||||
pan->gain[i][j] /= t;
|
||||
}
|
||||
av_opt_set_int(pan->swr, "icl", link->channel_layout, 0);
|
||||
@@ -335,7 +339,7 @@ static int config_props(AVFilterLink *link)
|
||||
// summary
|
||||
for (i = 0; i < pan->nb_output_channels; i++) {
|
||||
cur = buf;
|
||||
for (j = 0; j < pan->nb_input_channels; j++) {
|
||||
for (j = 0; j < link->channels; j++) {
|
||||
r = snprintf(cur, buf + sizeof(buf) - cur, "%s%.3g i%d",
|
||||
j ? " + " : "", pan->gain[i][j], j);
|
||||
cur += FFMIN(buf + sizeof(buf) - cur, r);
|
||||
|
@@ -109,7 +109,7 @@ static int init(AVFilterContext *ctx)
|
||||
|
||||
if (eval->chlayout_str) {
|
||||
int n;
|
||||
ret = ff_parse_channel_layout(&eval->chlayout, eval->chlayout_str, ctx);
|
||||
ret = ff_parse_channel_layout(&eval->chlayout, NULL, eval->chlayout_str, ctx);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
|
||||
|
@@ -68,7 +68,7 @@ static int init(AVFilterContext *ctx)
|
||||
null->sample_rate_str, ctx)) < 0)
|
||||
return ret;
|
||||
|
||||
if ((ret = ff_parse_channel_layout(&null->channel_layout,
|
||||
if ((ret = ff_parse_channel_layout(&null->channel_layout, NULL,
|
||||
null->channel_layout_str, ctx)) < 0)
|
||||
return ret;
|
||||
|
||||
|
@@ -110,8 +110,8 @@ void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
|
||||
|
||||
(*count)++;
|
||||
for (i = idx + 1; i < *count; i++)
|
||||
if (*links[i])
|
||||
(*(unsigned *)((uint8_t *) *links[i] + padidx_off))++;
|
||||
if ((*links)[i])
|
||||
(*(unsigned *)((uint8_t *) (*links)[i] + padidx_off))++;
|
||||
}
|
||||
|
||||
int avfilter_link(AVFilterContext *src, unsigned srcpad,
|
||||
@@ -468,7 +468,7 @@ int avfilter_register(AVFilter *filter)
|
||||
|
||||
filter->next = NULL;
|
||||
|
||||
while(avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
|
||||
while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
|
||||
f = &(*f)->next;
|
||||
|
||||
return 0;
|
||||
|
@@ -575,6 +575,10 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref)
|
||||
av_log(link->src, AV_LOG_ERROR, "Cannot select channel layout for"
|
||||
" the link between filters %s and %s.\n", link->src->name,
|
||||
link->dst->name);
|
||||
if (!link->in_channel_layouts->all_counts)
|
||||
av_log(link->src, AV_LOG_ERROR, "Unknown channel layouts not "
|
||||
"supported, try specifying a channel layout using "
|
||||
"'aformat=channel_layouts=something'.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
link->in_channel_layouts->nb_channel_layouts = 1;
|
||||
@@ -657,7 +661,8 @@ static int reduce_formats_on_filter(AVFilterContext *filter)
|
||||
if (inlink->type != outlink->type || fmts->nb_channel_layouts == 1)
|
||||
continue;
|
||||
|
||||
if (fmts->all_layouts) {
|
||||
if (fmts->all_layouts &&
|
||||
(!FF_LAYOUT2COUNT(fmt) || fmts->all_counts)) {
|
||||
/* Turn the infinite list into a singleton */
|
||||
fmts->all_layouts = fmts->all_counts = 0;
|
||||
ff_add_channel_layout(&outlink->in_channel_layouts, fmt);
|
||||
|
@@ -629,10 +629,21 @@ int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx)
|
||||
int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg,
|
||||
void *log_ctx)
|
||||
{
|
||||
char *tail;
|
||||
int64_t chlayout = av_get_channel_layout(arg);
|
||||
int64_t chlayout, count;
|
||||
|
||||
if (nret) {
|
||||
count = strtol(arg, &tail, 10);
|
||||
if (*tail == 'c' && !tail[1] && count > 0 && count < 63) {
|
||||
*nret = count;
|
||||
*ret = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
chlayout = av_get_channel_layout(arg);
|
||||
if (chlayout == 0) {
|
||||
chlayout = strtol(arg, &tail, 10);
|
||||
if (*tail || chlayout == 0) {
|
||||
@@ -641,6 +652,8 @@ int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx)
|
||||
}
|
||||
}
|
||||
*ret = chlayout;
|
||||
if (nret)
|
||||
*nret = av_get_channel_layout_nb_channels(chlayout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -217,11 +217,14 @@ int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx);
|
||||
* Parse a channel layout or a corresponding integer representation.
|
||||
*
|
||||
* @param ret 64bit integer pointer to where the value should be written.
|
||||
* @param nret integer pointer to the number of channels;
|
||||
* if not NULL, then unknown channel layouts are accepted
|
||||
* @param arg string to parse
|
||||
* @param log_ctx log context
|
||||
* @return 0 in case of success, a negative AVERROR code on error
|
||||
*/
|
||||
int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx);
|
||||
int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg,
|
||||
void *log_ctx);
|
||||
|
||||
void ff_update_link_current_pts(AVFilterLink *link, int64_t pts);
|
||||
|
||||
|
@@ -54,7 +54,7 @@ void av_register_input_format(AVInputFormat *format)
|
||||
AVInputFormat **p = &first_iformat;
|
||||
|
||||
format->next = NULL;
|
||||
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
|
||||
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
|
||||
p = &(*p)->next;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ void av_register_output_format(AVOutputFormat *format)
|
||||
AVOutputFormat **p = &first_oformat;
|
||||
|
||||
format->next = NULL;
|
||||
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
|
||||
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
|
||||
p = &(*p)->next;
|
||||
}
|
||||
|
||||
|
@@ -164,16 +164,26 @@ static int gif_read_ext(AVFormatContext *s)
|
||||
if ((ret = avio_skip(pb, sb_size - 3)) < 0 )
|
||||
return ret;
|
||||
} else if (ext_label == GIF_APP_EXT_LABEL) {
|
||||
uint8_t netscape_ext[sizeof(NETSCAPE_EXT_STR)-1 + 2];
|
||||
uint8_t data[256];
|
||||
|
||||
if ((sb_size = avio_r8(pb)) != strlen(NETSCAPE_EXT_STR))
|
||||
return 0;
|
||||
ret = avio_read(pb, netscape_ext, sizeof(netscape_ext));
|
||||
if (ret < sizeof(netscape_ext))
|
||||
sb_size = avio_r8(pb);
|
||||
ret = avio_read(pb, data, sb_size);
|
||||
if (ret < 0 || !sb_size)
|
||||
return ret;
|
||||
gdc->total_iter = avio_rl16(pb);
|
||||
if (gdc->total_iter == 0)
|
||||
gdc->total_iter = -1;
|
||||
|
||||
if (sb_size == strlen(NETSCAPE_EXT_STR)) {
|
||||
sb_size = avio_r8(pb);
|
||||
ret = avio_read(pb, data, sb_size);
|
||||
if (ret < 0 || !sb_size)
|
||||
return ret;
|
||||
|
||||
if (sb_size == 3 && data[0] == 1) {
|
||||
gdc->total_iter = AV_RL16(data+1);
|
||||
|
||||
if (gdc->total_iter == 0)
|
||||
gdc->total_iter = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((ret = gif_skip_subblocks(pb)) < 0)
|
||||
|
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/avstring.h"
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/opt.h"
|
||||
@@ -37,6 +38,7 @@ typedef struct {
|
||||
int split_planes; /**< use independent file for each Y, U, V plane */
|
||||
char path[1024];
|
||||
int update;
|
||||
const char *muxer;
|
||||
} VideoMuxData;
|
||||
|
||||
static int write_header(AVFormatContext *s)
|
||||
@@ -44,7 +46,6 @@ static int write_header(AVFormatContext *s)
|
||||
VideoMuxData *img = s->priv_data;
|
||||
AVStream *st = s->streams[0];
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codec->pix_fmt);
|
||||
const char *str;
|
||||
|
||||
av_strlcpy(img->path, s->filename, sizeof(img->path));
|
||||
|
||||
@@ -54,14 +55,18 @@ static int write_header(AVFormatContext *s)
|
||||
else
|
||||
img->is_pipe = 1;
|
||||
|
||||
str = strrchr(img->path, '.');
|
||||
if (st->codec->codec_id == AV_CODEC_ID_GIF) {
|
||||
img->muxer = "gif";
|
||||
} else if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO) {
|
||||
const char *str = strrchr(img->path, '.');
|
||||
/* TODO: reindent */
|
||||
img->split_planes = str
|
||||
&& !av_strcasecmp(str + 1, "y")
|
||||
&& s->nb_streams == 1
|
||||
&& st->codec->codec_id == AV_CODEC_ID_RAWVIDEO
|
||||
&& desc
|
||||
&&(desc->flags & AV_PIX_FMT_FLAG_PLANAR)
|
||||
&& desc->nb_components >= 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -115,6 +120,37 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
avio_write(pb[3], pkt->data + ysize + 2*usize, ysize);
|
||||
avio_close(pb[3]);
|
||||
}
|
||||
} else if (img->muxer) {
|
||||
int ret;
|
||||
AVStream *st;
|
||||
AVPacket pkt2 = {0};
|
||||
AVFormatContext *fmt = NULL;
|
||||
|
||||
av_assert0(!img->split_planes);
|
||||
|
||||
ret = avformat_alloc_output_context2(&fmt, NULL, img->muxer, s->filename);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
st = avformat_new_stream(fmt, NULL);
|
||||
if (!st) {
|
||||
avformat_free_context(fmt);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
st->id = pkt->stream_index;
|
||||
|
||||
fmt->pb = pb[0];
|
||||
if ((ret = av_copy_packet(&pkt2, pkt)) < 0 ||
|
||||
(ret = av_dup_packet(&pkt2)) < 0 ||
|
||||
(ret = avcodec_copy_context(st->codec, s->streams[0]->codec)) < 0 ||
|
||||
(ret = avformat_write_header(fmt, NULL)) < 0 ||
|
||||
(ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 ||
|
||||
(ret = av_write_trailer(fmt)) < 0) {
|
||||
av_free_packet(&pkt2);
|
||||
avformat_free_context(fmt);
|
||||
return ret;
|
||||
}
|
||||
av_free_packet(&pkt2);
|
||||
avformat_free_context(fmt);
|
||||
} else {
|
||||
avio_write(pb[0], pkt->data, pkt->size);
|
||||
}
|
||||
|
@@ -1829,7 +1829,8 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
|
||||
1000000000, track->default_duration, 30000);
|
||||
#if FF_API_R_FRAME_RATE
|
||||
st->r_frame_rate = st->avg_frame_rate;
|
||||
if (st->avg_frame_rate.num < st->avg_frame_rate.den * 1000L)
|
||||
st->r_frame_rate = st->avg_frame_rate;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -1697,6 +1697,8 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
if (!entries)
|
||||
{
|
||||
sc->keyframe_absent = 1;
|
||||
if (!st->need_parsing)
|
||||
st->need_parsing = AVSTREAM_PARSE_HEADERS;
|
||||
return 0;
|
||||
}
|
||||
if (entries >= UINT_MAX / sizeof(int))
|
||||
|
@@ -288,6 +288,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
|
||||
AVStream *st = s->streams[0];
|
||||
int64_t ret = av_index_search_timestamp(st, timestamp, flags);
|
||||
int i, j;
|
||||
int dir = (flags&AVSEEK_FLAG_BACKWARD) ? -1 : 1;
|
||||
|
||||
if (mp3->is_cbr && st->duration > 0 && mp3->header_filesize > s->data_offset) {
|
||||
int64_t filesize = avio_size(s->pb);
|
||||
@@ -317,7 +318,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
|
||||
|
||||
#define MIN_VALID 3
|
||||
for(i=0; i<4096; i++) {
|
||||
int64_t pos = ie->pos + i;
|
||||
int64_t pos = ie->pos + i*dir;
|
||||
for(j=0; j<MIN_VALID; j++) {
|
||||
ret = check(s, pos);
|
||||
if(ret < 0)
|
||||
@@ -330,7 +331,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
|
||||
if(j!=MIN_VALID)
|
||||
i=0;
|
||||
|
||||
ret = avio_seek(s->pb, ie->pos + i, SEEK_SET);
|
||||
ret = avio_seek(s->pb, ie->pos + i*dir, SEEK_SET);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ff_update_cur_dts(s, st, ie->timestamp);
|
||||
|
@@ -26,15 +26,15 @@
|
||||
|
||||
typedef struct ThpDemuxContext {
|
||||
int version;
|
||||
int first_frame;
|
||||
int first_framesz;
|
||||
int last_frame;
|
||||
unsigned first_frame;
|
||||
unsigned first_framesz;
|
||||
unsigned last_frame;
|
||||
int compoff;
|
||||
int framecnt;
|
||||
unsigned framecnt;
|
||||
AVRational fps;
|
||||
int frame;
|
||||
int next_frame;
|
||||
int next_framesz;
|
||||
unsigned frame;
|
||||
int64_t next_frame;
|
||||
unsigned next_framesz;
|
||||
int video_stream_index;
|
||||
int audio_stream_index;
|
||||
int compcount;
|
||||
@@ -158,7 +158,7 @@ static int thp_read_packet(AVFormatContext *s,
|
||||
avio_seek(pb, thp->next_frame, SEEK_SET);
|
||||
|
||||
/* Locate the next frame and read out its size. */
|
||||
thp->next_frame += thp->next_framesz;
|
||||
thp->next_frame += FFMAX(thp->next_framesz, 1);
|
||||
thp->next_framesz = avio_rb32(pb);
|
||||
|
||||
avio_rb32(pb); /* Previous total size. */
|
||||
|
@@ -1061,12 +1061,14 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
|
||||
if (pkt->dts != AV_NOPTS_VALUE) {
|
||||
// got DTS from the stream, update reference timestamp
|
||||
st->reference_dts = pkt->dts - pc->dts_ref_dts_delta * num / den;
|
||||
pkt->pts = pkt->dts + pc->pts_dts_delta * num / den;
|
||||
} else if (st->reference_dts != AV_NOPTS_VALUE) {
|
||||
// compute DTS based on reference timestamp
|
||||
pkt->dts = st->reference_dts + pc->dts_ref_dts_delta * num / den;
|
||||
pkt->pts = pkt->dts + pc->pts_dts_delta * num / den;
|
||||
}
|
||||
|
||||
if (st->reference_dts != AV_NOPTS_VALUE && pkt->pts == AV_NOPTS_VALUE)
|
||||
pkt->pts = pkt->dts + pc->pts_dts_delta * num / den;
|
||||
|
||||
if (pc->dts_sync_point > 0)
|
||||
st->reference_dts = pkt->dts; // new reference
|
||||
}
|
||||
@@ -2791,9 +2793,10 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
|
||||
goto find_stream_info_err;
|
||||
}
|
||||
|
||||
read_size += pkt->size;
|
||||
|
||||
st = ic->streams[pkt->stream_index];
|
||||
if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC))
|
||||
read_size += pkt->size;
|
||||
|
||||
if (pkt->dts != AV_NOPTS_VALUE && st->codec_info_nb_frames > 1) {
|
||||
/* check for non-increasing dts */
|
||||
if (st->info->fps_last_dts != AV_NOPTS_VALUE &&
|
||||
|
@@ -396,11 +396,15 @@ break_loop:
|
||||
|
||||
avio_seek(pb, data_ofs, SEEK_SET);
|
||||
|
||||
if (!sample_count && st->codec->channels &&
|
||||
av_get_bits_per_sample(st->codec->codec_id) && wav->data_end <= avio_size(pb))
|
||||
sample_count = (data_size << 3) /
|
||||
(st->codec->channels *
|
||||
(uint64_t)av_get_bits_per_sample(st->codec->codec_id));
|
||||
if (!sample_count || av_get_exact_bits_per_sample(st->codec->codec_id) > 0)
|
||||
if ( st->codec->channels
|
||||
&& data_size
|
||||
&& av_get_bits_per_sample(st->codec->codec_id)
|
||||
&& wav->data_end <= avio_size(pb))
|
||||
sample_count = (data_size << 3)
|
||||
/
|
||||
(st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
|
||||
|
||||
if (sample_count)
|
||||
st->duration = sample_count;
|
||||
|
||||
@@ -458,8 +462,8 @@ static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if (wav->smv_data_ofs > 0) {
|
||||
int64_t audio_dts, video_dts;
|
||||
smv_retry:
|
||||
audio_dts = s->streams[0]->cur_dts;
|
||||
video_dts = s->streams[1]->cur_dts;
|
||||
audio_dts = (int32_t)s->streams[0]->cur_dts;
|
||||
video_dts = (int32_t)s->streams[1]->cur_dts;
|
||||
|
||||
if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) {
|
||||
/*We always return a video frame first to get the pixel format first*/
|
||||
|
@@ -89,7 +89,8 @@ OBJS = adler32.o \
|
||||
intfloat_readwrite.o \
|
||||
intmath.o \
|
||||
lfg.o \
|
||||
lls.o \
|
||||
lls1.o \
|
||||
lls2.o \
|
||||
log.o \
|
||||
log2_tab.o \
|
||||
mathematics.o \
|
||||
@@ -142,7 +143,8 @@ TESTPROGS = adler32 \
|
||||
fifo \
|
||||
hmac \
|
||||
lfg \
|
||||
lls \
|
||||
lls1 \
|
||||
lls2 \
|
||||
md5 \
|
||||
murmur3 \
|
||||
opt \
|
||||
|
@@ -30,14 +30,23 @@
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
#include "lls.h"
|
||||
#include "lls1.h"
|
||||
|
||||
static void update_lls(LLSModel *m, double *var)
|
||||
#if FF_API_LLS1
|
||||
|
||||
av_cold void avpriv_init_lls(LLSModel *m, int indep_count)
|
||||
{
|
||||
memset(m, 0, sizeof(LLSModel));
|
||||
m->indep_count = indep_count;
|
||||
}
|
||||
|
||||
void avpriv_update_lls(LLSModel *m, double *var, double decay)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i <= m->indep_count; i++) {
|
||||
for (j = i; j <= m->indep_count; j++) {
|
||||
m->covariance[i][j] *= decay;
|
||||
m->covariance[i][j] += var[i] * var[j];
|
||||
}
|
||||
}
|
||||
@@ -46,8 +55,8 @@ static void update_lls(LLSModel *m, double *var)
|
||||
void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order)
|
||||
{
|
||||
int i, j, k;
|
||||
double (*factor)[MAX_VARS_ALIGN] = (void *) &m->covariance[1][0];
|
||||
double (*covar) [MAX_VARS_ALIGN] = (void *) &m->covariance[1][1];
|
||||
double (*factor)[MAX_VARS + 1] = (void *) &m->covariance[1][0];
|
||||
double (*covar) [MAX_VARS + 1] = (void *) &m->covariance[1][1];
|
||||
double *covar_y = m->covariance[0];
|
||||
int count = m->indep_count;
|
||||
|
||||
@@ -100,7 +109,7 @@ void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order)
|
||||
}
|
||||
}
|
||||
|
||||
static double evaluate_lls(LLSModel *m, double *param, int order)
|
||||
double avpriv_evaluate_lls(LLSModel *m, double *param, int order)
|
||||
{
|
||||
int i;
|
||||
double out = 0;
|
||||
@@ -111,16 +120,6 @@ static double evaluate_lls(LLSModel *m, double *param, int order)
|
||||
return out;
|
||||
}
|
||||
|
||||
av_cold void avpriv_init_lls(LLSModel *m, int indep_count)
|
||||
{
|
||||
memset(m, 0, sizeof(LLSModel));
|
||||
m->indep_count = indep_count;
|
||||
m->update_lls = update_lls;
|
||||
m->evaluate_lls = evaluate_lls;
|
||||
if (ARCH_X86)
|
||||
ff_init_lls_x86(m);
|
||||
}
|
||||
|
||||
#if FF_API_LLS_PRIVATE
|
||||
av_cold void av_init_lls(LLSModel *m, int indep_count)
|
||||
{
|
||||
@@ -128,7 +127,7 @@ av_cold void av_init_lls(LLSModel *m, int indep_count)
|
||||
}
|
||||
void av_update_lls(LLSModel *m, double *param, double decay)
|
||||
{
|
||||
m->update_lls(m, param);
|
||||
avpriv_update_lls(m, param, decay);
|
||||
}
|
||||
void av_solve_lls(LLSModel *m, double threshold, int min_order)
|
||||
{
|
||||
@@ -136,10 +135,12 @@ void av_solve_lls(LLSModel *m, double threshold, int min_order)
|
||||
}
|
||||
double av_evaluate_lls(LLSModel *m, double *param, int order)
|
||||
{
|
||||
return m->evaluate_lls(m, param, order);
|
||||
return avpriv_evaluate_lls(m, param, order);
|
||||
}
|
||||
#endif /* FF_API_LLS_PRIVATE */
|
||||
|
||||
#endif /* FF_API_LLS1 */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -156,17 +157,17 @@ int main(void)
|
||||
avpriv_init_lls(&m, 3);
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
LOCAL_ALIGNED(32, double, var, [4]);
|
||||
double var[4];
|
||||
double eval;
|
||||
|
||||
var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2;
|
||||
var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
|
||||
var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
|
||||
var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
|
||||
m.update_lls(&m, var);
|
||||
avpriv_update_lls(&m, var, 0.99);
|
||||
avpriv_solve_lls(&m, 0.001, 0);
|
||||
for (order = 0; order < 3; order++) {
|
||||
eval = m.evaluate_lls(&m, var + 1, order);
|
||||
eval = avpriv_evaluate_lls(&m, var + 1, order);
|
||||
printf("real:%9f order:%d pred:%9f var:%f coeffs:%f %9f %9f\n",
|
||||
var[0], order, eval, sqrt(m.variance[order] / (i + 1)),
|
||||
m.coeff[order][0], m.coeff[order][1],
|
54
libavutil/lls1.h
Normal file
54
libavutil/lls1.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* linear least squares model
|
||||
*
|
||||
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* 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 AVUTIL_LLS_H
|
||||
#define AVUTIL_LLS_H
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#define MAX_VARS 32
|
||||
|
||||
//FIXME avoid direct access to LLSModel from outside
|
||||
|
||||
/**
|
||||
* Linear least squares model.
|
||||
*/
|
||||
typedef struct LLSModel {
|
||||
double covariance[MAX_VARS + 1][MAX_VARS + 1];
|
||||
double coeff[MAX_VARS][MAX_VARS];
|
||||
double variance[MAX_VARS];
|
||||
int indep_count;
|
||||
} LLSModel;
|
||||
|
||||
void avpriv_init_lls(LLSModel *m, int indep_count);
|
||||
void avpriv_update_lls(LLSModel *m, double *param, double decay);
|
||||
void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order);
|
||||
double avpriv_evaluate_lls(LLSModel *m, double *param, int order);
|
||||
|
||||
#if FF_API_LLS_PRIVATE
|
||||
void av_init_lls(LLSModel *m, int indep_count);
|
||||
void av_update_lls(LLSModel *m, double *param, double decay);
|
||||
void av_solve_lls(LLSModel *m, double threshold, int min_order);
|
||||
double av_evaluate_lls(LLSModel *m, double *param, int order);
|
||||
#endif /* FF_API_LLS_PRIVATE */
|
||||
|
||||
#endif /* AVUTIL_LLS_H */
|
160
libavutil/lls2.c
Normal file
160
libavutil/lls2.c
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* linear least squares model
|
||||
*
|
||||
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* linear least squares model
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
#include "lls2.h"
|
||||
|
||||
static void update_lls(LLSModel2 *m, double *var)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i <= m->indep_count; i++) {
|
||||
for (j = i; j <= m->indep_count; j++) {
|
||||
m->covariance[i][j] += var[i] * var[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void avpriv_solve_lls2(LLSModel2 *m, double threshold, unsigned short min_order)
|
||||
{
|
||||
int i, j, k;
|
||||
double (*factor)[MAX_VARS_ALIGN] = (void *) &m->covariance[1][0];
|
||||
double (*covar) [MAX_VARS_ALIGN] = (void *) &m->covariance[1][1];
|
||||
double *covar_y = m->covariance[0];
|
||||
int count = m->indep_count;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
for (j = i; j < count; j++) {
|
||||
double sum = covar[i][j];
|
||||
|
||||
for (k = i - 1; k >= 0; k--)
|
||||
sum -= factor[i][k] * factor[j][k];
|
||||
|
||||
if (i == j) {
|
||||
if (sum < threshold)
|
||||
sum = 1.0;
|
||||
factor[i][i] = sqrt(sum);
|
||||
} else {
|
||||
factor[j][i] = sum / factor[i][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
double sum = covar_y[i + 1];
|
||||
|
||||
for (k = i - 1; k >= 0; k--)
|
||||
sum -= factor[i][k] * m->coeff[0][k];
|
||||
|
||||
m->coeff[0][i] = sum / factor[i][i];
|
||||
}
|
||||
|
||||
for (j = count - 1; j >= min_order; j--) {
|
||||
for (i = j; i >= 0; i--) {
|
||||
double sum = m->coeff[0][i];
|
||||
|
||||
for (k = i + 1; k <= j; k++)
|
||||
sum -= factor[k][i] * m->coeff[j][k];
|
||||
|
||||
m->coeff[j][i] = sum / factor[i][i];
|
||||
}
|
||||
|
||||
m->variance[j] = covar_y[0];
|
||||
|
||||
for (i = 0; i <= j; i++) {
|
||||
double sum = m->coeff[j][i] * covar[i][i] - 2 * covar_y[i + 1];
|
||||
|
||||
for (k = 0; k < i; k++)
|
||||
sum += 2 * m->coeff[j][k] * covar[k][i];
|
||||
|
||||
m->variance[j] += m->coeff[j][i] * sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static double evaluate_lls(LLSModel2 *m, double *param, int order)
|
||||
{
|
||||
int i;
|
||||
double out = 0;
|
||||
|
||||
for (i = 0; i <= order; i++)
|
||||
out += param[i] * m->coeff[order][i];
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
av_cold void avpriv_init_lls2(LLSModel2 *m, int indep_count)
|
||||
{
|
||||
memset(m, 0, sizeof(LLSModel2));
|
||||
m->indep_count = indep_count;
|
||||
m->update_lls = update_lls;
|
||||
m->evaluate_lls = evaluate_lls;
|
||||
if (ARCH_X86)
|
||||
ff_init_lls_x86(m);
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include "lfg.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
LLSModel2 m;
|
||||
int i, order;
|
||||
AVLFG lfg;
|
||||
|
||||
av_lfg_init(&lfg, 1);
|
||||
avpriv_init_lls2(&m, 3);
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
LOCAL_ALIGNED(32, double, var, [4]);
|
||||
double eval;
|
||||
|
||||
var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2;
|
||||
var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
|
||||
var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
|
||||
var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
|
||||
m.update_lls(&m, var);
|
||||
avpriv_solve_lls2(&m, 0.001, 0);
|
||||
for (order = 0; order < 3; order++) {
|
||||
eval = m.evaluate_lls(&m, var + 1, order);
|
||||
printf("real:%9f order:%d pred:%9f var:%f coeffs:%f %9f %9f\n",
|
||||
var[0], order, eval, sqrt(m.variance[order] / (i + 1)),
|
||||
m.coeff[order][0], m.coeff[order][1],
|
||||
m.coeff[order][2]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@@ -30,12 +30,12 @@
|
||||
#define MAX_VARS 32
|
||||
#define MAX_VARS_ALIGN FFALIGN(MAX_VARS+1,4)
|
||||
|
||||
//FIXME avoid direct access to LLSModel from outside
|
||||
//FIXME avoid direct access to LLSModel2 from outside
|
||||
|
||||
/**
|
||||
* Linear least squares model.
|
||||
*/
|
||||
typedef struct LLSModel {
|
||||
typedef struct LLSModel2 {
|
||||
DECLARE_ALIGNED(32, double, covariance[MAX_VARS_ALIGN][MAX_VARS_ALIGN]);
|
||||
DECLARE_ALIGNED(32, double, coeff[MAX_VARS][MAX_VARS]);
|
||||
double variance[MAX_VARS];
|
||||
@@ -47,25 +47,18 @@ typedef struct LLSModel {
|
||||
* 32-byte aligned, and any padding elements must be initialized
|
||||
* (i.e not denormal/nan).
|
||||
*/
|
||||
void (*update_lls)(struct LLSModel *m, double *var);
|
||||
void (*update_lls)(struct LLSModel2 *m, double *var);
|
||||
/**
|
||||
* Inner product of var[] and the LPC coefs.
|
||||
* @param m this context
|
||||
* @param var training samples, excluding the value to be predicted. unaligned.
|
||||
* @param order lpc order
|
||||
*/
|
||||
double (*evaluate_lls)(struct LLSModel *m, double *var, int order);
|
||||
} LLSModel;
|
||||
double (*evaluate_lls)(struct LLSModel2 *m, double *var, int order);
|
||||
} LLSModel2;
|
||||
|
||||
void avpriv_init_lls(LLSModel *m, int indep_count);
|
||||
void ff_init_lls_x86(LLSModel *m);
|
||||
void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order);
|
||||
|
||||
#if FF_API_LLS_PRIVATE
|
||||
void av_init_lls(LLSModel *m, int indep_count);
|
||||
void av_update_lls(LLSModel *m, double *param, double decay);
|
||||
void av_solve_lls(LLSModel *m, double threshold, int min_order);
|
||||
double av_evaluate_lls(LLSModel *m, double *param, int order);
|
||||
#endif /* FF_API_LLS_PRIVATE */
|
||||
void avpriv_init_lls2(LLSModel2 *m, int indep_count);
|
||||
void ff_init_lls_x86(LLSModel2 *m);
|
||||
void avpriv_solve_lls2(LLSModel2 *m, double threshold, unsigned short min_order);
|
||||
|
||||
#endif /* AVUTIL_LLS_H */
|
@@ -103,6 +103,9 @@ static int use_color = -1;
|
||||
|
||||
static void colored_fputs(int level, const char *str)
|
||||
{
|
||||
if (!*str)
|
||||
return;
|
||||
|
||||
if (use_color < 0) {
|
||||
#if HAVE_SETCONSOLETEXTATTRIBUTE
|
||||
CONSOLE_SCREEN_BUFFER_INFO con_info;
|
||||
|
@@ -251,7 +251,7 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons
|
||||
|
||||
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0;
|
||||
void *dst, *target_obj;
|
||||
const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
|
||||
if (!o || !target_obj)
|
||||
|
@@ -132,6 +132,9 @@
|
||||
#ifndef FF_API_LLS_PRIVATE
|
||||
#define FF_API_LLS_PRIVATE (LIBAVUTIL_VERSION_MAJOR < 53)
|
||||
#endif
|
||||
#ifndef FF_API_LLS1
|
||||
#define FF_API_LLS1 (LIBAVUTIL_VERSION_MAJOR < 53)
|
||||
#endif
|
||||
#ifndef FF_API_AVFRAME_LAVC
|
||||
#define FF_API_AVFRAME_LAVC (LIBAVUTIL_VERSION_MAJOR < 53)
|
||||
#endif
|
||||
|
@@ -29,7 +29,7 @@ SECTION .text
|
||||
%define COVAR_STRIDE MAX_VARS_ALIGN*8
|
||||
%define COVAR(x,y) [covarq + (x)*8 + (y)*COVAR_STRIDE]
|
||||
|
||||
struc LLSModel
|
||||
struc LLSModel2
|
||||
.covariance: resq MAX_VARS_ALIGN*MAX_VARS_ALIGN
|
||||
.coeff: resq MAX_VARS*MAX_VARS
|
||||
.variance: resq MAX_VARS
|
||||
@@ -49,7 +49,7 @@ INIT_XMM sse2
|
||||
%define movdqa movaps
|
||||
cglobal update_lls, 2,5,8, ctx, var, i, j, covar2
|
||||
%define covarq ctxq
|
||||
mov id, [ctxq + LLSModel.indep_count]
|
||||
mov id, [ctxq + LLSModel2.indep_count]
|
||||
lea varq, [varq + iq*8]
|
||||
neg iq
|
||||
mov covar2q, covarq
|
||||
@@ -129,7 +129,7 @@ cglobal update_lls, 2,5,8, ctx, var, i, j, covar2
|
||||
INIT_YMM avx
|
||||
cglobal update_lls, 3,6,8, ctx, var, count, i, j, count2
|
||||
%define covarq ctxq
|
||||
mov countd, [ctxq + LLSModel.indep_count]
|
||||
mov countd, [ctxq + LLSModel2.indep_count]
|
||||
lea count2d, [countq-2]
|
||||
xor id, id
|
||||
.loopi:
|
||||
@@ -206,7 +206,7 @@ cglobal evaluate_lls, 3,4,2, ctx, var, order, i
|
||||
%define coefsq ctxq
|
||||
mov id, orderd
|
||||
imul orderd, MAX_VARS
|
||||
lea coefsq, [ctxq + LLSModel.coeff + orderq*8]
|
||||
lea coefsq, [ctxq + LLSModel2.coeff + orderq*8]
|
||||
movsd m0, [varq]
|
||||
movhpd m0, [varq + 8]
|
||||
mulpd m0, [coefsq]
|
||||
|
@@ -20,14 +20,14 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavutil/lls.h"
|
||||
#include "libavutil/lls2.h"
|
||||
#include "libavutil/x86/cpu.h"
|
||||
|
||||
void ff_update_lls_sse2(LLSModel *m, double *var);
|
||||
void ff_update_lls_avx(LLSModel *m, double *var);
|
||||
double ff_evaluate_lls_sse2(LLSModel *m, double *var, int order);
|
||||
void ff_update_lls_sse2(LLSModel2 *m, double *var);
|
||||
void ff_update_lls_avx(LLSModel2 *m, double *var);
|
||||
double ff_evaluate_lls_sse2(LLSModel2 *m, double *var, int order);
|
||||
|
||||
av_cold void ff_init_lls_x86(LLSModel *m)
|
||||
av_cold void ff_init_lls_x86(LLSModel2 *m)
|
||||
{
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||
|
@@ -424,8 +424,8 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus
|
||||
off = len1 * out->bps;
|
||||
}
|
||||
|
||||
av_assert0(out->ch_count == av_get_channel_layout_nb_channels(s->out_ch_layout));
|
||||
av_assert0(in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout));
|
||||
av_assert0(!s->out_ch_layout || out->ch_count == av_get_channel_layout_nb_channels(s->out_ch_layout));
|
||||
av_assert0(!s-> in_ch_layout || in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout));
|
||||
|
||||
for(out_i=0; out_i<out->ch_count; out_i++){
|
||||
switch(s->matrix_ch[out_i][0]){
|
||||
|
@@ -1268,9 +1268,10 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
|
||||
dst_stride <<= 1;
|
||||
|
||||
if (INLINE_MMXEXT(cpu_flags) && c->srcBpc == 8 && c->dstBpc <= 14) {
|
||||
c->canMMXEXTBeUsed = (dstW >= srcW && (dstW & 31) == 0 &&
|
||||
(srcW & 15) == 0) ? 1 : 0;
|
||||
if (!c->canMMXEXTBeUsed && dstW >= srcW && (srcW & 15) == 0
|
||||
c->canMMXEXTBeUsed = dstW >= srcW && (dstW & 31) == 0 &&
|
||||
c->chrDstW >= c->chrSrcW &&
|
||||
(srcW & 15) == 0;
|
||||
if (!c->canMMXEXTBeUsed && dstW >= srcW && c->chrDstW >= c->chrSrcW && (srcW & 15) == 0
|
||||
|
||||
&& (flags & SWS_FAST_BILINEAR)) {
|
||||
if (flags & SWS_PRINT_INFO)
|
||||
|
Reference in New Issue
Block a user