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: mpegenc: use avctx->slices as number of slices v410enc: fix undefined signed left shift caused by integer promotion Release notes: mention cleaned up header includes fix Changelog file Fix a bunch of typos. Drop some pointless void* return value casts from av_malloc() invocations. wavpack: fix typos in previous cosmetic clean-up commit wavpack: cosmetics: K&R pretty-printing avconv: remove the 'codec framerate is different from stream' warning wavpack: determine sample_fmt before requesting a buffer bmv audio: implement new audio decoding API mpegaudiodec: skip all channels when skipping granules mpegenc: simplify muxrate calculation Conflicts: Changelog avconv.c doc/RELEASE_NOTES libavcodec/h264.c libavcodec/mpeg12.c libavcodec/mpegaudiodec.c libavcodec/mpegvideo.c libavformat/mpegenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
7d8f115843
@ -13,8 +13,6 @@ version next:
|
|||||||
- tinterlace video filter
|
- tinterlace video filter
|
||||||
- astreamsync audio filter
|
- astreamsync audio filter
|
||||||
- amerge audio filter
|
- amerge audio filter
|
||||||
- Indeo 4 decoder
|
|
||||||
- SMJPEG demuxer
|
|
||||||
- Automatic thread count based on detection number of (available) CPU cores
|
- Automatic thread count based on detection number of (available) CPU cores
|
||||||
- y41p Brooktree Uncompressed 4:1:1 12-bit encoder and decoder
|
- y41p Brooktree Uncompressed 4:1:1 12-bit encoder and decoder
|
||||||
|
|
||||||
@ -153,6 +151,8 @@ easier to use. The changes are:
|
|||||||
- Dxtory capture format decoder
|
- Dxtory capture format decoder
|
||||||
- cellauto source
|
- cellauto source
|
||||||
- Simple segmenting muxer
|
- Simple segmenting muxer
|
||||||
|
- Indeo 4 decoder
|
||||||
|
- SMJPEG demuxer
|
||||||
|
|
||||||
|
|
||||||
version 0.8:
|
version 0.8:
|
||||||
|
11
avconv.c
11
avconv.c
@ -3196,7 +3196,7 @@ static AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *
|
|||||||
*/
|
*/
|
||||||
static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
||||||
{
|
{
|
||||||
int i, rfps, rfps_base;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ic->nb_streams; i++) {
|
for (i = 0; i < ic->nb_streams; i++) {
|
||||||
AVStream *st = ic->streams[i];
|
AVStream *st = ic->streams[i];
|
||||||
@ -3225,19 +3225,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
|||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
if(!ist->dec)
|
if(!ist->dec)
|
||||||
ist->dec = avcodec_find_decoder(dec->codec_id);
|
ist->dec = avcodec_find_decoder(dec->codec_id);
|
||||||
rfps = ic->streams[i]->r_frame_rate.num;
|
|
||||||
rfps_base = ic->streams[i]->r_frame_rate.den;
|
|
||||||
if (dec->lowres) {
|
if (dec->lowres) {
|
||||||
dec->flags |= CODEC_FLAG_EMU_EDGE;
|
dec->flags |= CODEC_FLAG_EMU_EDGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dec->time_base.den != rfps * dec->ticks_per_frame || dec->time_base.num != rfps_base) {
|
|
||||||
|
|
||||||
av_log(NULL, AV_LOG_INFO,"\nSeems stream %d codec frame rate differs from container frame rate: %2.2f (%d/%d) -> %2.2f (%d/%d)\n",
|
|
||||||
i, (float)dec->time_base.den / dec->time_base.num, dec->time_base.den, dec->time_base.num,
|
|
||||||
(float)rfps / rfps_base, rfps, rfps_base);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o->video_disable)
|
if (o->video_disable)
|
||||||
st->discard = AVDISCARD_ALL;
|
st->discard = AVDISCARD_ALL;
|
||||||
else if (video_discard)
|
else if (video_discard)
|
||||||
|
11
ffmpeg.c
11
ffmpeg.c
@ -3463,7 +3463,7 @@ static AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *
|
|||||||
*/
|
*/
|
||||||
static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
||||||
{
|
{
|
||||||
int i, rfps, rfps_base;
|
int i;
|
||||||
char *next, *codec_tag = NULL;
|
char *next, *codec_tag = NULL;
|
||||||
|
|
||||||
for (i = 0; i < ic->nb_streams; i++) {
|
for (i = 0; i < ic->nb_streams; i++) {
|
||||||
@ -3501,19 +3501,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
|||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
if(!ist->dec)
|
if(!ist->dec)
|
||||||
ist->dec = avcodec_find_decoder(dec->codec_id);
|
ist->dec = avcodec_find_decoder(dec->codec_id);
|
||||||
rfps = ic->streams[i]->r_frame_rate.num;
|
|
||||||
rfps_base = ic->streams[i]->r_frame_rate.den;
|
|
||||||
if (dec->lowres) {
|
if (dec->lowres) {
|
||||||
dec->flags |= CODEC_FLAG_EMU_EDGE;
|
dec->flags |= CODEC_FLAG_EMU_EDGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dec->time_base.den != rfps * dec->ticks_per_frame || dec->time_base.num != rfps_base) {
|
|
||||||
|
|
||||||
av_log(NULL, AV_LOG_INFO,"\nSeems stream %d codec frame rate differs from container frame rate: %2.2f (%d/%d) -> %2.2f (%d/%d)\n",
|
|
||||||
i, (float)dec->time_base.den / dec->time_base.num, dec->time_base.den, dec->time_base.num,
|
|
||||||
(float)rfps / rfps_base, rfps, rfps_base);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o->video_disable)
|
if (o->video_disable)
|
||||||
st->discard = AVDISCARD_ALL;
|
st->discard = AVDISCARD_ALL;
|
||||||
else if (video_discard)
|
else if (video_discard)
|
||||||
|
@ -285,12 +285,17 @@ static av_cold int decode_end(AVCodecContext *avctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct BMVAudioDecContext {
|
||||||
|
AVFrame frame;
|
||||||
|
} BMVAudioDecContext;
|
||||||
|
|
||||||
static const int bmv_aud_mults[16] = {
|
static const int bmv_aud_mults[16] = {
|
||||||
16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32
|
16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32
|
||||||
};
|
};
|
||||||
|
|
||||||
static av_cold int bmv_aud_decode_init(AVCodecContext *avctx)
|
static av_cold int bmv_aud_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
|
BMVAudioDecContext *c = avctx->priv_data;
|
||||||
|
|
||||||
if (avctx->channels != 2) {
|
if (avctx->channels != 2) {
|
||||||
av_log(avctx, AV_LOG_INFO, "invalid number of channels\n");
|
av_log(avctx, AV_LOG_INFO, "invalid number of channels\n");
|
||||||
@ -299,17 +304,21 @@ static av_cold int bmv_aud_decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||||
|
|
||||||
|
avcodec_get_frame_defaults(&c->frame);
|
||||||
|
avctx->coded_frame = &c->frame;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
AVPacket *avpkt)
|
int *got_frame_ptr, AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
|
BMVAudioDecContext *c = avctx->priv_data;
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
int blocks = 0, total_blocks, i;
|
int blocks = 0, total_blocks, i;
|
||||||
int out_size;
|
int ret;
|
||||||
int16_t *output_samples = data;
|
int16_t *output_samples;
|
||||||
int scale[2];
|
int scale[2];
|
||||||
|
|
||||||
total_blocks = *buf++;
|
total_blocks = *buf++;
|
||||||
@ -318,11 +327,14 @@ static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data, int *data_siz
|
|||||||
total_blocks * 65 + 1, buf_size);
|
total_blocks * 65 + 1, buf_size);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
out_size = total_blocks * 64 * sizeof(*output_samples);
|
|
||||||
if (*data_size < out_size) {
|
/* get output buffer */
|
||||||
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
c->frame.nb_samples = total_blocks * 32;
|
||||||
return AVERROR(EINVAL);
|
if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
output_samples = (int16_t *)c->frame.data[0];
|
||||||
|
|
||||||
for (blocks = 0; blocks < total_blocks; blocks++) {
|
for (blocks = 0; blocks < total_blocks; blocks++) {
|
||||||
uint8_t code = *buf++;
|
uint8_t code = *buf++;
|
||||||
@ -335,7 +347,9 @@ static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data, int *data_siz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*data_size = out_size;
|
*got_frame_ptr = 1;
|
||||||
|
*(AVFrame *)data = c->frame;
|
||||||
|
|
||||||
return buf_size;
|
return buf_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +368,9 @@ AVCodec ff_bmv_audio_decoder = {
|
|||||||
.name = "bmv_audio",
|
.name = "bmv_audio",
|
||||||
.type = AVMEDIA_TYPE_AUDIO,
|
.type = AVMEDIA_TYPE_AUDIO,
|
||||||
.id = CODEC_ID_BMV_AUDIO,
|
.id = CODEC_ID_BMV_AUDIO,
|
||||||
|
.priv_data_size = sizeof(BMVAudioDecContext),
|
||||||
.init = bmv_aud_decode_init,
|
.init = bmv_aud_decode_init,
|
||||||
.decode = bmv_aud_decode_frame,
|
.decode = bmv_aud_decode_frame,
|
||||||
|
.capabilities = CODEC_CAP_DR1,
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Discworld II BMV audio"),
|
.long_name = NULL_IF_CONFIG_SMALL("Discworld II BMV audio"),
|
||||||
};
|
};
|
||||||
|
@ -50,7 +50,11 @@ static void decode_mb(MpegEncContext *s, int ref){
|
|||||||
h->mb_xy= s->mb_x + s->mb_y*s->mb_stride;
|
h->mb_xy= s->mb_x + s->mb_y*s->mb_stride;
|
||||||
memset(h->non_zero_count_cache, 0, sizeof(h->non_zero_count_cache));
|
memset(h->non_zero_count_cache, 0, sizeof(h->non_zero_count_cache));
|
||||||
assert(ref>=0);
|
assert(ref>=0);
|
||||||
if(ref >= h->ref_count[0]) //FIXME it is posible albeit uncommon that slice references differ between slices, we take the easy approuch and ignore it for now. If this turns out to have any relevance in practice then correct remapping should be added
|
/* FIXME: It is posible albeit uncommon that slice references
|
||||||
|
* differ between slices. We take the easy approach and ignore
|
||||||
|
* it for now. If this turns out to have any relevance in
|
||||||
|
* practice then correct remapping should be added. */
|
||||||
|
if (ref >= h->ref_count[0])
|
||||||
ref=0;
|
ref=0;
|
||||||
fill_rectangle(&s->current_picture.f.ref_index[0][4*h->mb_xy], 2, 2, 2, ref, 1);
|
fill_rectangle(&s->current_picture.f.ref_index[0][4*h->mb_xy], 2, 2, 2, ref, 1);
|
||||||
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
|
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
|
||||||
@ -684,7 +688,7 @@ static int is_intra_more_likely(MpegEncContext *s){
|
|||||||
if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration && s->pict_type == AV_PICTURE_TYPE_I)
|
if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration && s->pict_type == AV_PICTURE_TYPE_I)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
skip_amount= FFMAX(undamaged_count/50, 1); //check only upto 50 MBs
|
skip_amount = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs
|
||||||
is_intra_likely=0;
|
is_intra_likely=0;
|
||||||
|
|
||||||
j=0;
|
j=0;
|
||||||
|
@ -1315,7 +1315,6 @@ int ff_h264_frame_start(H264Context *h){
|
|||||||
MpegEncContext * const s = &h->s;
|
MpegEncContext * const s = &h->s;
|
||||||
int i;
|
int i;
|
||||||
const int pixel_shift = h->pixel_shift;
|
const int pixel_shift = h->pixel_shift;
|
||||||
int thread_count = (s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1;
|
|
||||||
|
|
||||||
if(MPV_frame_start(s, s->avctx) < 0)
|
if(MPV_frame_start(s, s->avctx) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1345,7 +1344,7 @@ int ff_h264_frame_start(H264Context *h){
|
|||||||
|
|
||||||
/* can't be in alloc_tables because linesize isn't known there.
|
/* can't be in alloc_tables because linesize isn't known there.
|
||||||
* FIXME: redo bipred weight to not require extra buffer? */
|
* FIXME: redo bipred weight to not require extra buffer? */
|
||||||
for(i = 0; i < thread_count; i++)
|
for(i = 0; i < s->slice_context_count; i++)
|
||||||
if(h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad)
|
if(h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad)
|
||||||
h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*6*s->linesize);
|
h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*6*s->linesize);
|
||||||
|
|
||||||
@ -2852,7 +2851,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(i = 1; i < s->avctx->thread_count; i++) {
|
for(i = 1; i < s->slice_context_count; i++) {
|
||||||
H264Context *c;
|
H264Context *c;
|
||||||
c = h->thread_context[i] = av_malloc(sizeof(H264Context));
|
c = h->thread_context[i] = av_malloc(sizeof(H264Context));
|
||||||
memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext));
|
memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext));
|
||||||
@ -2866,7 +2865,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
|||||||
clone_tables(c, h, i);
|
clone_tables(c, h, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < s->avctx->thread_count; i++)
|
for(i = 0; i < s->slice_context_count; i++)
|
||||||
if (context_init(h->thread_context[i]) < 0) {
|
if (context_init(h->thread_context[i]) < 0) {
|
||||||
av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed.\n");
|
av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed.\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -3782,7 +3781,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
|||||||
|
|
||||||
h->nal_unit_type= 0;
|
h->nal_unit_type= 0;
|
||||||
|
|
||||||
h->max_contexts = (HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_SLICE)) ? avctx->thread_count : 1;
|
if(!s->slice_context_count)
|
||||||
|
s->slice_context_count= 1;
|
||||||
|
h->max_contexts = s->slice_context_count;
|
||||||
|
|
||||||
if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
|
if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
|
||||||
h->current_slice = 0;
|
h->current_slice = 0;
|
||||||
if (!s->first_field)
|
if (!s->first_field)
|
||||||
|
@ -885,7 +885,7 @@ static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
|
|||||||
uint8_t *src_m1, *src_0, *src_p1, *src_p2;
|
uint8_t *src_m1, *src_0, *src_p1, *src_p2;
|
||||||
int y;
|
int y;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
buf = (uint8_t*)av_malloc(width);
|
buf = av_malloc(width);
|
||||||
|
|
||||||
src_m1 = src1;
|
src_m1 = src1;
|
||||||
memcpy(buf,src_m1,width);
|
memcpy(buf,src_m1,width);
|
||||||
|
@ -2485,7 +2485,9 @@ static int decode_chunks(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) {
|
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) {
|
||||||
int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count;
|
int threshold = (s2->mb_height * s->slice_count +
|
||||||
|
s2->slice_context_count / 2) /
|
||||||
|
s2->slice_context_count;
|
||||||
av_assert0(avctx->thread_count > 1);
|
av_assert0(avctx->thread_count > 1);
|
||||||
if (threshold <= mb_y) {
|
if (threshold <= mb_y) {
|
||||||
MpegEncContext *thread_context = s2->thread_context[s->slice_count];
|
MpegEncContext *thread_context = s2->thread_context[s->slice_count];
|
||||||
|
@ -1427,6 +1427,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!s->adu_mode) {
|
if (!s->adu_mode) {
|
||||||
|
int skip;
|
||||||
const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
|
const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
|
||||||
assert((get_bits_count(&s->gb) & 7) == 0);
|
assert((get_bits_count(&s->gb) & 7) == 0);
|
||||||
/* now we get bits from the main_data_begin offset */
|
/* now we get bits from the main_data_begin offset */
|
||||||
|
@ -638,6 +638,8 @@ void MPV_common_defaults(MpegEncContext *s)
|
|||||||
|
|
||||||
s->picture_range_start = 0;
|
s->picture_range_start = 0;
|
||||||
s->picture_range_end = MAX_PICTURE_COUNT;
|
s->picture_range_end = MAX_PICTURE_COUNT;
|
||||||
|
|
||||||
|
s->slice_context_count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -656,11 +658,13 @@ void MPV_decode_defaults(MpegEncContext *s)
|
|||||||
*/
|
*/
|
||||||
av_cold int MPV_common_init(MpegEncContext *s)
|
av_cold int MPV_common_init(MpegEncContext *s)
|
||||||
{
|
{
|
||||||
int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y,
|
int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
|
||||||
threads = (s->encoding ||
|
int nb_slices = (HAVE_THREADS &&
|
||||||
(HAVE_THREADS &&
|
s->avctx->active_thread_type & FF_THREAD_SLICE) ?
|
||||||
s->avctx->active_thread_type & FF_THREAD_SLICE)) ?
|
s->avctx->thread_count : 1;
|
||||||
s->avctx->thread_count : 1;
|
|
||||||
|
if (s->encoding && s->avctx->slices)
|
||||||
|
nb_slices = s->avctx->slices;
|
||||||
|
|
||||||
if (s->codec_id == CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
|
if (s->codec_id == CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
|
||||||
s->mb_height = (s->height + 31) / 32 * 2;
|
s->mb_height = (s->height + 31) / 32 * 2;
|
||||||
@ -673,14 +677,15 @@ av_cold int MPV_common_init(MpegEncContext *s)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s->encoding || (s->avctx->active_thread_type & FF_THREAD_SLICE)) &&
|
if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && s->mb_height)) {
|
||||||
(s->avctx->thread_count > MAX_THREADS ||
|
int max_slices;
|
||||||
(s->avctx->thread_count > s->mb_height && s->mb_height))) {
|
if (s->mb_height)
|
||||||
int max_threads = FFMIN(MAX_THREADS, s->mb_height);
|
max_slices = FFMIN(MAX_THREADS, s->mb_height);
|
||||||
av_log(s->avctx, AV_LOG_WARNING,
|
else
|
||||||
"too many threads (%d), reducing to %d\n",
|
max_slices = MAX_THREADS;
|
||||||
s->avctx->thread_count, max_threads);
|
av_log(s->avctx, AV_LOG_WARNING, "too many threads/slices (%d),"
|
||||||
threads = max_threads;
|
" reducing to %d\n", nb_slices, max_slices);
|
||||||
|
nb_slices = max_slices;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s->width || s->height) &&
|
if ((s->width || s->height) &&
|
||||||
@ -831,17 +836,20 @@ av_cold int MPV_common_init(MpegEncContext *s)
|
|||||||
s->context_initialized = 1;
|
s->context_initialized = 1;
|
||||||
s->thread_context[0] = s;
|
s->thread_context[0] = s;
|
||||||
|
|
||||||
if (s->encoding || (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_SLICE)) {
|
// if (s->width && s->height) {
|
||||||
for (i = 1; i < threads; i++) {
|
if (nb_slices > 1) {
|
||||||
|
for (i = 1; i < nb_slices; i++) {
|
||||||
s->thread_context[i] = av_malloc(sizeof(MpegEncContext));
|
s->thread_context[i] = av_malloc(sizeof(MpegEncContext));
|
||||||
memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
|
memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < threads; i++) {
|
for (i = 0; i < nb_slices; i++) {
|
||||||
if (init_duplicate_context(s->thread_context[i], s) < 0)
|
if (init_duplicate_context(s->thread_context[i], s) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
s->thread_context[i]->start_mb_y = (s->mb_height*(i ) + s->avctx->thread_count / 2) / s->avctx->thread_count;
|
s->thread_context[i]->start_mb_y =
|
||||||
s->thread_context[i]->end_mb_y = (s->mb_height*(i+1) + s->avctx->thread_count / 2) / s->avctx->thread_count;
|
(s->mb_height * (i) + nb_slices / 2) / nb_slices;
|
||||||
|
s->thread_context[i]->end_mb_y =
|
||||||
|
(s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (init_duplicate_context(s, s) < 0)
|
if (init_duplicate_context(s, s) < 0)
|
||||||
@ -849,6 +857,8 @@ av_cold int MPV_common_init(MpegEncContext *s)
|
|||||||
s->start_mb_y = 0;
|
s->start_mb_y = 0;
|
||||||
s->end_mb_y = s->mb_height;
|
s->end_mb_y = s->mb_height;
|
||||||
}
|
}
|
||||||
|
s->slice_context_count = nb_slices;
|
||||||
|
// }
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
@ -861,13 +871,14 @@ void MPV_common_end(MpegEncContext *s)
|
|||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
if (s->encoding || (HAVE_THREADS && s->avctx->active_thread_type & FF_THREAD_SLICE)) {
|
if (s->slice_context_count > 1) {
|
||||||
for (i = 0; i < s->avctx->thread_count; i++) {
|
for (i = 0; i < s->slice_context_count; i++) {
|
||||||
free_duplicate_context(s->thread_context[i]);
|
free_duplicate_context(s->thread_context[i]);
|
||||||
}
|
}
|
||||||
for (i = 1; i < s->avctx->thread_count; i++) {
|
for (i = 1; i < s->slice_context_count; i++) {
|
||||||
av_freep(&s->thread_context[i]);
|
av_freep(&s->thread_context[i]);
|
||||||
}
|
}
|
||||||
|
s->slice_context_count = 1;
|
||||||
} else free_duplicate_context(s);
|
} else free_duplicate_context(s);
|
||||||
|
|
||||||
av_freep(&s->parse_context.buffer);
|
av_freep(&s->parse_context.buffer);
|
||||||
|
@ -270,6 +270,7 @@ typedef struct MpegEncContext {
|
|||||||
int start_mb_y; ///< start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
|
int start_mb_y; ///< start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
|
||||||
int end_mb_y; ///< end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
|
int end_mb_y; ///< end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
|
||||||
struct MpegEncContext *thread_context[MAX_THREADS];
|
struct MpegEncContext *thread_context[MAX_THREADS];
|
||||||
|
int slice_context_count; ///< number of used thread_contexts
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* copy of the previous picture structure.
|
* copy of the previous picture structure.
|
||||||
|
@ -1435,7 +1435,8 @@ int MPV_encode_picture(AVCodecContext *avctx,
|
|||||||
{
|
{
|
||||||
MpegEncContext *s = avctx->priv_data;
|
MpegEncContext *s = avctx->priv_data;
|
||||||
AVFrame *pic_arg = data;
|
AVFrame *pic_arg = data;
|
||||||
int i, stuffing_count, context_count = avctx->thread_count;
|
int i, stuffing_count;
|
||||||
|
int context_count = s->slice_context_count;
|
||||||
|
|
||||||
for (i = 0; i < context_count; i++) {
|
for (i = 0; i < context_count; i++) {
|
||||||
int start_y = s->thread_context[i]->start_mb_y;
|
int start_y = s->thread_context[i]->start_mb_y;
|
||||||
@ -3072,7 +3073,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int bits;
|
int bits;
|
||||||
int context_count = s->avctx->thread_count;
|
int context_count = s->slice_context_count;
|
||||||
|
|
||||||
s->picture_number = picture_number;
|
s->picture_number = picture_number;
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ static const AVOption options[]={
|
|||||||
{"cholesky", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_CHOLESKY }, INT_MIN, INT_MAX, A|E, "lpc_type"},
|
{"cholesky", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_CHOLESKY }, INT_MIN, INT_MAX, A|E, "lpc_type"},
|
||||||
{"lpc_passes", "deprecated, use flac-specific options", OFFSET(lpc_passes), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
|
{"lpc_passes", "deprecated, use flac-specific options", OFFSET(lpc_passes), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
|
||||||
#endif
|
#endif
|
||||||
{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|E},
|
{"slices", "number of slices, used in parallelized encoding", OFFSET(slices), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|E},
|
||||||
{"thread_type", "select multithreading type", OFFSET(thread_type), AV_OPT_TYPE_FLAGS, {.dbl = FF_THREAD_SLICE|FF_THREAD_FRAME }, 0, INT_MAX, V|E|D, "thread_type"},
|
{"thread_type", "select multithreading type", OFFSET(thread_type), AV_OPT_TYPE_FLAGS, {.dbl = FF_THREAD_SLICE|FF_THREAD_FRAME }, 0, INT_MAX, V|E|D, "thread_type"},
|
||||||
{"slice", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_THREAD_SLICE }, INT_MIN, INT_MAX, V|E|D, "thread_type"},
|
{"slice", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_THREAD_SLICE }, INT_MIN, INT_MAX, V|E|D, "thread_type"},
|
||||||
{"frame", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_THREAD_FRAME }, INT_MIN, INT_MAX, V|E|D, "thread_type"},
|
{"frame", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_THREAD_FRAME }, INT_MIN, INT_MAX, V|E|D, "thread_type"},
|
||||||
|
@ -516,9 +516,9 @@ static void halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *fr
|
|||||||
int ls= frame->linesize[p];
|
int ls= frame->linesize[p];
|
||||||
uint8_t *src= frame->data[p];
|
uint8_t *src= frame->data[p];
|
||||||
|
|
||||||
halfpel[1][p]= (uint8_t*)av_malloc(ls * (h+2*EDGE_WIDTH)) + EDGE_WIDTH*(1+ls);
|
halfpel[1][p] = av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
|
||||||
halfpel[2][p]= (uint8_t*)av_malloc(ls * (h+2*EDGE_WIDTH)) + EDGE_WIDTH*(1+ls);
|
halfpel[2][p] = av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
|
||||||
halfpel[3][p]= (uint8_t*)av_malloc(ls * (h+2*EDGE_WIDTH)) + EDGE_WIDTH*(1+ls);
|
halfpel[3][p] = av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
|
||||||
|
|
||||||
halfpel[0][p]= src;
|
halfpel[0][p]= src;
|
||||||
for(y=0; y<h; y++){
|
for(y=0; y<h; y++){
|
||||||
|
@ -67,7 +67,7 @@ static int v410_encode_frame(AVCodecContext *avctx, uint8_t *buf,
|
|||||||
for (j = 0; j < avctx->width; j++) {
|
for (j = 0; j < avctx->width; j++) {
|
||||||
val = u[j] << 2;
|
val = u[j] << 2;
|
||||||
val |= y[j] << 12;
|
val |= y[j] << 12;
|
||||||
val |= v[j] << 22;
|
val |= (uint32_t) v[j] << 22;
|
||||||
AV_WL32(dst, val);
|
AV_WL32(dst, val);
|
||||||
dst += 4;
|
dst += 4;
|
||||||
output_size += 4;
|
output_size += 4;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -606,7 +606,7 @@ static int mms_read(URLContext *h, uint8_t *buf, int size)
|
|||||||
// copy the data to the packet buffer.
|
// copy the data to the packet buffer.
|
||||||
result = ff_mms_read_data(mms, buf, size);
|
result = ff_mms_read_data(mms, buf, size);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
av_dlog(NULL, "read asf media paket size is zero!\n");
|
av_dlog(NULL, "Read ASF media packet size is zero!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ static int mpeg_mux_init(AVFormatContext *ctx)
|
|||||||
if (!s->mux_rate) {
|
if (!s->mux_rate) {
|
||||||
/* we increase slightly the bitrate to take into account the
|
/* we increase slightly the bitrate to take into account the
|
||||||
headers. XXX: compute it exactly */
|
headers. XXX: compute it exactly */
|
||||||
bitrate += bitrate*5LL/100;
|
bitrate += bitrate / 20;
|
||||||
bitrate += 10000;
|
bitrate += 10000;
|
||||||
s->mux_rate = (bitrate + (8 * 50) - 1) / (8 * 50);
|
s->mux_rate = (bitrate + (8 * 50) - 1) / (8 * 50);
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* XXX: suppress this malloc */
|
/* XXX: suppress this malloc */
|
||||||
buf1= (uint8_t*) av_malloc( size * sizeof(uint8_t) );
|
buf1 = av_malloc(size * sizeof(uint8_t));
|
||||||
|
|
||||||
write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY));
|
write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY));
|
||||||
|
|
||||||
|
@ -3369,14 +3369,14 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[
|
|||||||
linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,
|
linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,
|
||||||
FFMAX(height-y-copyAhead, 0), srcStride);
|
FFMAX(height-y-copyAhead, 0), srcStride);
|
||||||
|
|
||||||
/* duplicate last line of src to fill the void upto line (copyAhead+7) */
|
/* duplicate last line of src to fill the void up to line (copyAhead+7) */
|
||||||
for(i=FFMAX(height-y, 8); i<copyAhead+8; i++)
|
for(i=FFMAX(height-y, 8); i<copyAhead+8; i++)
|
||||||
memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride));
|
memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride));
|
||||||
|
|
||||||
/* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/
|
/* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/
|
||||||
linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride);
|
linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride);
|
||||||
|
|
||||||
/* duplicate last line of dst to fill the void upto line (copyAhead) */
|
/* duplicate last line of dst to fill the void up to line (copyAhead) */
|
||||||
for(i=height-y+1; i<=copyAhead; i++)
|
for(i=height-y+1; i<=copyAhead; i++)
|
||||||
memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride));
|
memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride));
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, funcNum;
|
int i, funcNum;
|
||||||
uint8_t *srcBuffer= (uint8_t*)av_malloc(SIZE);
|
uint8_t *srcBuffer = av_malloc(SIZE);
|
||||||
uint8_t *dstBuffer= (uint8_t*)av_malloc(SIZE);
|
uint8_t *dstBuffer = av_malloc(SIZE);
|
||||||
int failedNum=0;
|
int failedNum=0;
|
||||||
int passedNum=0;
|
int passedNum=0;
|
||||||
|
|
||||||
|
@ -62,13 +62,13 @@ fi
|
|||||||
|
|
||||||
if [ -n "$do_mpeg2thread" ] ; then
|
if [ -n "$do_mpeg2thread" ] ; then
|
||||||
# mpeg2 encoding interlaced
|
# mpeg2 encoding interlaced
|
||||||
do_video_encoding mpeg2thread.mpg "-qscale 10 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 2"
|
do_video_encoding mpeg2thread.mpg "-qscale 10 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 2 -slices 2"
|
||||||
do_video_decoding
|
do_video_decoding
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$do_mpeg2thread_ilace" ]; then
|
if [ -n "$do_mpeg2thread_ilace" ]; then
|
||||||
# mpeg2 encoding interlaced using intra vlc
|
# mpeg2 encoding interlaced using intra vlc
|
||||||
do_video_encoding mpeg2threadivlc.mpg "-qscale 10 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -flags2 +ivlc -threads 2"
|
do_video_encoding mpeg2threadivlc.mpg "-qscale 10 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -flags2 +ivlc -threads 2 -slices 2"
|
||||||
do_video_decoding
|
do_video_decoding
|
||||||
|
|
||||||
# mpeg2 encoding interlaced
|
# mpeg2 encoding interlaced
|
||||||
@ -158,7 +158,7 @@ do_video_decoding
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$do_mpeg4thread" ] ; then
|
if [ -n "$do_mpeg4thread" ] ; then
|
||||||
do_video_encoding mpeg4-thread.avi "-b 500k -flags +mv4+part+aic -trellis 1 -mbd bits -ps 200 -bf 2 -an -vcodec mpeg4 -threads 2"
|
do_video_encoding mpeg4-thread.avi "-b 500k -flags +mv4+part+aic -trellis 1 -mbd bits -ps 200 -bf 2 -an -vcodec mpeg4 -threads 2 -slices 2"
|
||||||
do_video_decoding
|
do_video_decoding
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ $EGREP $OPT '^\+ *(const *|)static' $*| $EGREP --color=always '[^=]= *(0|NULL)[^
|
|||||||
cat $TMP
|
cat $TMP
|
||||||
hiegrep '# *ifdef * (HAVE|CONFIG)_' 'ifdefs that should be #if' $*
|
hiegrep '# *ifdef * (HAVE|CONFIG)_' 'ifdefs that should be #if' $*
|
||||||
|
|
||||||
hiegrep '\b(awnser|cant|dont|wont|usefull|successfull|occured|teh|alot|wether|skiped|heigth|informations|colums|loosy|loosing|seperate|preceed)\b' 'common typos' $*
|
hiegrep '\b(awnser|cant|dont|wont|usefull|successfull|occured|teh|alot|wether|skiped|heigth|informations|colums|loosy|loosing|seperate|preceed|upto|paket)\b' 'common typos' $*
|
||||||
|
|
||||||
hiegrep 'av_log\( *NULL' 'Missing context in av_log' $*
|
hiegrep 'av_log\( *NULL' 'Missing context in av_log' $*
|
||||||
hiegrep '[^sn]printf' 'Please use av_log' $*
|
hiegrep '[^sn]printf' 'Please use av_log' $*
|
||||||
|
Loading…
Reference in New Issue
Block a user