mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Merge remote-tracking branch 'qatar/master'
* qatar/master: drawtext: remove typo pcm-mpeg: implement new audio decoding api w32thread: port fixes to pthread_cond_broadcast() from x264. doc: add editor configuration section with Vim and Emacs settings dxva2.h: include d3d9.h to define LPDIRECT3DSURFACE9 avformat/utils: Drop unused goto label. doxygen: Replace '\' by '@' in Doxygen markup tags. cosmetics: drop some completely pointless parentheses cljr: simplify CLJRContext drawtext: introduce rand(min, max) drawtext: introduce explicit draw/hide variable rtmp: Use nb_invokes for all invoke commands Conflicts: libavcodec/mpegvideo.c libavfilter/vf_drawtext.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
8e2bab5d4b
@ -179,6 +179,31 @@ Casts should be used only when necessary. Unneeded parentheses
|
||||
should also be avoided if they don't make the code easier to understand.
|
||||
@end itemize
|
||||
|
||||
@subsection Editor configuration
|
||||
In order to configure Vim to follow Libav formatting conventions, paste
|
||||
the following snippet into your @file{.vimrc}:
|
||||
@example
|
||||
" indentation rules for libav: 4 spaces, no tabs
|
||||
set expandtab
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
" allow tabs in Makefiles
|
||||
autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=8
|
||||
" Trailing whitespace and tabs are forbidden, so highlight them.
|
||||
highlight ForbiddenWhitespace ctermbg=red guibg=red
|
||||
match ForbiddenWhitespace /\s\+$\|\t/
|
||||
" Do not highlight spaces at the end of line while typing on that line.
|
||||
autocmd InsertEnter * match ForbiddenWhitespace /\t\|\s\+\%#\@@<!$/
|
||||
@end example
|
||||
|
||||
For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
|
||||
@example
|
||||
(setq c-default-style "k&r")
|
||||
(setq-default c-basic-offset 4)
|
||||
(setq-default indent-tabs-mode nil)
|
||||
(setq-default show-trailing-whitespace t)
|
||||
@end example
|
||||
|
||||
@section Development Policy
|
||||
|
||||
@enumerate
|
||||
|
@ -708,9 +708,10 @@ static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_
|
||||
memset(pSnd->IMDCT_buf, 0, 512 * sizeof(float));
|
||||
|
||||
/* gain compensation and overlapping */
|
||||
gainCompensateAndOverlap (pSnd->IMDCT_buf, &(pSnd->prevFrame[band*256]), &(pOut[band*256]),
|
||||
&((pSnd->gainBlock[1 - (pSnd->gcBlkSwitch)]).gBlock[band]),
|
||||
&((pSnd->gainBlock[pSnd->gcBlkSwitch]).gBlock[band]));
|
||||
gainCompensateAndOverlap(pSnd->IMDCT_buf, &pSnd->prevFrame[band * 256],
|
||||
&pOut[band * 256],
|
||||
&pSnd->gainBlock[1 - pSnd->gcBlkSwitch].gBlock[band],
|
||||
&pSnd->gainBlock[ pSnd->gcBlkSwitch].gBlock[band]);
|
||||
}
|
||||
|
||||
/* Swap the gain control buffers for the next frame. */
|
||||
@ -795,7 +796,9 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf,
|
||||
for (i=0 ; i<q->channels ; i++) {
|
||||
|
||||
/* Set the bitstream reader at the start of a channel sound unit. */
|
||||
init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels), (q->bits_per_frame)/q->channels);
|
||||
init_get_bits(&q->gb,
|
||||
databuf + i * q->bytes_per_frame / q->channels,
|
||||
q->bits_per_frame / q->channels);
|
||||
|
||||
result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[i], out_samples[i], i, q->codingMode);
|
||||
if (result != 0)
|
||||
|
@ -35,9 +35,6 @@
|
||||
typedef struct CLJRContext{
|
||||
AVCodecContext *avctx;
|
||||
AVFrame picture;
|
||||
int delta[16];
|
||||
int offset[4];
|
||||
GetBitContext gb;
|
||||
} CLJRContext;
|
||||
|
||||
static int decode_frame(AVCodecContext *avctx,
|
||||
@ -47,6 +44,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
CLJRContext * const a = avctx->priv_data;
|
||||
GetBitContext gb;
|
||||
AVFrame *picture = data;
|
||||
AVFrame * const p= (AVFrame*)&a->picture;
|
||||
int x, y;
|
||||
@ -67,20 +65,20 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
p->pict_type= AV_PICTURE_TYPE_I;
|
||||
p->key_frame= 1;
|
||||
|
||||
init_get_bits(&a->gb, buf, buf_size * 8);
|
||||
init_get_bits(&gb, buf, buf_size * 8);
|
||||
|
||||
for(y=0; y<avctx->height; y++){
|
||||
uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ];
|
||||
uint8_t *cb= &a->picture.data[1][ y*a->picture.linesize[1] ];
|
||||
uint8_t *cr= &a->picture.data[2][ y*a->picture.linesize[2] ];
|
||||
for(x=0; x<avctx->width; x+=4){
|
||||
luma[3] = get_bits(&a->gb, 5) << 3;
|
||||
luma[2] = get_bits(&a->gb, 5) << 3;
|
||||
luma[1] = get_bits(&a->gb, 5) << 3;
|
||||
luma[0] = get_bits(&a->gb, 5) << 3;
|
||||
luma[3] = get_bits(&gb, 5) << 3;
|
||||
luma[2] = get_bits(&gb, 5) << 3;
|
||||
luma[1] = get_bits(&gb, 5) << 3;
|
||||
luma[0] = get_bits(&gb, 5) << 3;
|
||||
luma+= 4;
|
||||
*(cb++) = get_bits(&a->gb, 6) << 2;
|
||||
*(cr++) = get_bits(&a->gb, 6) << 2;
|
||||
*(cb++) = get_bits(&gb, 6) << 2;
|
||||
*(cr++) = get_bits(&gb, 6) << 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <dxva2api.h>
|
||||
|
||||
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
|
||||
|
@ -840,10 +840,14 @@ av_cold int MPV_common_init(MpegEncContext *s)
|
||||
FF_ALLOCZ_OR_GOTO(s->avctx, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE, fail);
|
||||
|
||||
s->parse_context.state = -1;
|
||||
if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)) {
|
||||
s->visualization_buffer[0] = av_malloc((s->mb_width * 16 + 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
|
||||
s->visualization_buffer[1] = av_malloc((s->mb_width * 16 + 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
|
||||
s->visualization_buffer[2] = av_malloc((s->mb_width * 16 + 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
|
||||
if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
|
||||
s->avctx->debug_mv) {
|
||||
s->visualization_buffer[0] = av_malloc((s->mb_width * 16 +
|
||||
2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
|
||||
s->visualization_buffer[1] = av_malloc((s->mb_width * 16 +
|
||||
2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
|
||||
s->visualization_buffer[2] = av_malloc((s->mb_width * 16 +
|
||||
2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH);
|
||||
}
|
||||
|
||||
s->context_initialized = 1;
|
||||
@ -1512,7 +1516,8 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
|
||||
}
|
||||
}
|
||||
|
||||
if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){
|
||||
if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
|
||||
s->avctx->debug_mv) {
|
||||
const int shift= 1 + s->quarter_sample;
|
||||
int mb_y;
|
||||
uint8_t *ptr;
|
||||
@ -1538,7 +1543,7 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
|
||||
int mb_x;
|
||||
for(mb_x=0; mb_x<s->mb_width; mb_x++){
|
||||
const int mb_index= mb_x + mb_y*s->mb_stride;
|
||||
if((s->avctx->debug_mv) && pict->motion_val){
|
||||
if (s->avctx->debug_mv && pict->motion_val) {
|
||||
int type;
|
||||
for(type=0; type<3; type++){
|
||||
int direction = 0;
|
||||
|
@ -585,7 +585,7 @@ static inline void chroma_4mv_motion(MpegEncContext *s,
|
||||
if (src_y == (s->height >> 1))
|
||||
dxy &= ~2;
|
||||
|
||||
offset = (src_y * (s->uvlinesize)) + src_x;
|
||||
offset = src_y * s->uvlinesize + src_x;
|
||||
ptr = ref_picture[1] + offset;
|
||||
if(s->flags&CODEC_FLAG_EMU_EDGE){
|
||||
if( (unsigned)src_x > (s->h_edge_pos>>1) - (dxy &1) - 8
|
||||
|
@ -138,8 +138,8 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
|
||||
uint32_t av_uninit(pix32);
|
||||
unsigned int width= FFABS(pic->linesize[0]) / (depth >> 3);
|
||||
|
||||
output = pic->data[0] + (avctx->height - 1) * pic->linesize[0];
|
||||
output_end = pic->data[0] + (avctx->height) * pic->linesize[0];
|
||||
output = pic->data[0] + (avctx->height - 1) * pic->linesize[0];
|
||||
output_end = pic->data[0] + avctx->height * pic->linesize[0];
|
||||
while(src < data + srcsize) {
|
||||
p1 = *src++;
|
||||
if(p1 == 0) { //Escape code
|
||||
|
@ -121,17 +121,30 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pcm_bluray_decode_frame(AVCodecContext *avctx,
|
||||
void *data,
|
||||
int *data_size,
|
||||
AVPacket *avpkt)
|
||||
typedef struct PCMBRDecode {
|
||||
AVFrame frame;
|
||||
} PCMBRDecode;
|
||||
|
||||
static av_cold int pcm_bluray_decode_init(AVCodecContext * avctx)
|
||||
{
|
||||
PCMBRDecode *s = avctx->priv_data;
|
||||
|
||||
avcodec_get_frame_defaults(&s->frame);
|
||||
avctx->coded_frame = &s->frame;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
|
||||
int *got_frame_ptr, AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *src = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
PCMBRDecode *s = avctx->priv_data;
|
||||
int num_source_channels, channel, retval;
|
||||
int sample_size, samples, output_size;
|
||||
int16_t *dst16 = data;
|
||||
int32_t *dst32 = data;
|
||||
int sample_size, samples;
|
||||
int16_t *dst16;
|
||||
int32_t *dst32;
|
||||
|
||||
if (buf_size < 4) {
|
||||
av_log(avctx, AV_LOG_ERROR, "PCM packet too small\n");
|
||||
@ -148,15 +161,14 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
|
||||
sample_size = (num_source_channels * avctx->bits_per_coded_sample) >> 3;
|
||||
samples = buf_size / sample_size;
|
||||
|
||||
output_size = samples * avctx->channels *
|
||||
(avctx->sample_fmt == AV_SAMPLE_FMT_S32 ? 4 : 2);
|
||||
if (output_size > *data_size) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Insufficient output buffer space (%d bytes, needed %d bytes)\n",
|
||||
*data_size, output_size);
|
||||
return -1;
|
||||
/* get output buffer */
|
||||
s->frame.nb_samples = samples;
|
||||
if ((retval = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return retval;
|
||||
}
|
||||
*data_size = output_size;
|
||||
dst16 = (int16_t *)s->frame.data[0];
|
||||
dst32 = (int32_t *)s->frame.data[0];
|
||||
|
||||
if (samples) {
|
||||
switch (avctx->channel_layout) {
|
||||
@ -167,7 +179,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
|
||||
samples *= num_source_channels;
|
||||
if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
|
||||
#if HAVE_BIGENDIAN
|
||||
memcpy(dst16, src, output_size);
|
||||
memcpy(dst16, src, buf_size);
|
||||
#else
|
||||
do {
|
||||
*dst16++ = bytestream_get_be16(&src);
|
||||
@ -291,10 +303,13 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
}
|
||||
|
||||
*got_frame_ptr = 1;
|
||||
*(AVFrame *)data = s->frame;
|
||||
|
||||
retval = src - avpkt->data;
|
||||
if (avctx->debug & FF_DEBUG_BITSTREAM)
|
||||
av_dlog(avctx, "pcm_bluray_decode_frame: decoded %d -> %d bytes\n",
|
||||
retval, *data_size);
|
||||
retval, buf_size);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -302,7 +317,10 @@ AVCodec ff_pcm_bluray_decoder = {
|
||||
.name = "pcm_bluray",
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = CODEC_ID_PCM_BLURAY,
|
||||
.priv_data_size = sizeof(PCMBRDecode),
|
||||
.init = pcm_bluray_decode_init,
|
||||
.decode = pcm_bluray_decode_frame,
|
||||
.capabilities = CODEC_CAP_DR1,
|
||||
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
|
||||
AV_SAMPLE_FMT_NONE},
|
||||
.long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for Blu-ray media"),
|
||||
|
@ -616,8 +616,8 @@ static inline void write16x4(uint8_t *dst, int dst_stride,
|
||||
*(dst_int+15*int_dst_stride) = *(src_int + 15);
|
||||
}
|
||||
|
||||
/** \brief performs a 6x16 transpose of data in src, and stores it to dst
|
||||
\todo FIXME: see if we can't spare some vec_lvsl() by them factorizing
|
||||
/** @brief performs a 6x16 transpose of data in src, and stores it to dst
|
||||
@todo FIXME: see if we can't spare some vec_lvsl() by them factorizing
|
||||
out of unaligned_load() */
|
||||
#define readAndTranspose16x6(src, src_stride, r8, r9, r10, r11, r12, r13) {\
|
||||
register vec_u8 r0 = unaligned_load(0, src); \
|
||||
|
@ -94,7 +94,7 @@ do { \
|
||||
} while (0)
|
||||
|
||||
|
||||
/** \brief loads unaligned vector \a *src with offset \a offset
|
||||
/** @brief loads unaligned vector @a *src with offset @a offset
|
||||
and returns it */
|
||||
static inline vector unsigned char unaligned_load(int offset, uint8_t *src)
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ void write_##type##_2d_array(const void *arg, int len, int len2)\
|
||||
/**
|
||||
* @name Predefined functions for printing tables
|
||||
*
|
||||
* \{
|
||||
* @{
|
||||
*/
|
||||
void write_int8_t_array (const int8_t *, int);
|
||||
void write_uint8_t_array (const uint8_t *, int);
|
||||
@ -69,7 +69,7 @@ void write_int8_t_2d_array (const void *, int, int);
|
||||
void write_uint8_t_2d_array (const void *, int, int);
|
||||
void write_uint32_t_2d_array(const void *, int, int);
|
||||
void write_float_2d_array (const void *, int, int);
|
||||
/** \} */ // end of printfuncs group
|
||||
/** @} */ // end of printfuncs group
|
||||
|
||||
#define WRITE_ARRAY(prefix, type, name) \
|
||||
do { \
|
||||
|
@ -236,7 +236,7 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v)
|
||||
if (s->mb_x) {
|
||||
topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1;
|
||||
fieldtx = v->fieldtx_plane[topleft_mb_pos];
|
||||
stride_y = (s->linesize) << fieldtx;
|
||||
stride_y = s->linesize << fieldtx;
|
||||
v_dist = (16 - fieldtx) >> (fieldtx == 0);
|
||||
s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0],
|
||||
s->dest[0] - 16 * s->linesize - 16,
|
||||
|
@ -115,9 +115,12 @@ static inline int pthread_mutex_unlock(pthread_mutex_t *m)
|
||||
/* for pre-Windows 6.0 platforms we need to define and use our own condition
|
||||
* variable and api */
|
||||
typedef struct {
|
||||
pthread_mutex_t mtx_broadcast;
|
||||
pthread_mutex_t mtx_waiter_count;
|
||||
volatile int waiter_count;
|
||||
HANDLE semaphore;
|
||||
HANDLE waiters_done;
|
||||
int is_broadcast;
|
||||
} win32_cond_t;
|
||||
|
||||
static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
|
||||
@ -136,8 +139,12 @@ static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
|
||||
win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL);
|
||||
if (!win32_cond->semaphore)
|
||||
return;
|
||||
win32_cond->waiters_done = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!win32_cond->waiters_done)
|
||||
return;
|
||||
|
||||
pthread_mutex_init(&win32_cond->mtx_waiter_count, NULL);
|
||||
pthread_mutex_init(&win32_cond->mtx_broadcast, NULL);
|
||||
}
|
||||
|
||||
static void pthread_cond_destroy(pthread_cond_t *cond)
|
||||
@ -149,7 +156,9 @@ static void pthread_cond_destroy(pthread_cond_t *cond)
|
||||
|
||||
/* non native condition variables */
|
||||
CloseHandle(win32_cond->semaphore);
|
||||
CloseHandle(win32_cond->waiters_done);
|
||||
pthread_mutex_destroy(&win32_cond->mtx_waiter_count);
|
||||
pthread_mutex_destroy(&win32_cond->mtx_broadcast);
|
||||
av_freep(&win32_cond);
|
||||
cond->ptr = NULL;
|
||||
}
|
||||
@ -157,41 +166,70 @@ static void pthread_cond_destroy(pthread_cond_t *cond)
|
||||
static void pthread_cond_broadcast(pthread_cond_t *cond)
|
||||
{
|
||||
win32_cond_t *win32_cond = cond->ptr;
|
||||
int have_waiter;
|
||||
|
||||
if (cond_broadcast) {
|
||||
cond_broadcast(cond);
|
||||
return;
|
||||
}
|
||||
|
||||
/* non native condition variables */
|
||||
pthread_mutex_lock(&win32_cond->mtx_broadcast);
|
||||
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
|
||||
have_waiter = 0;
|
||||
|
||||
if (win32_cond->waiter_count) {
|
||||
ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL);
|
||||
win32_cond->waiter_count = 0;
|
||||
win32_cond->is_broadcast = 1;
|
||||
have_waiter = 1;
|
||||
}
|
||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
||||
|
||||
if (have_waiter) {
|
||||
ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL);
|
||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
||||
WaitForSingleObject(win32_cond->waiters_done, INFINITE);
|
||||
win32_cond->is_broadcast = 0;
|
||||
} else
|
||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
||||
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
|
||||
}
|
||||
|
||||
static void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
||||
{
|
||||
win32_cond_t *win32_cond = cond->ptr;
|
||||
int last_waiter;
|
||||
if (cond_wait) {
|
||||
cond_wait(cond, mutex, INFINITE);
|
||||
return;
|
||||
}
|
||||
|
||||
/* non native condition variables */
|
||||
pthread_mutex_lock(&win32_cond->mtx_broadcast);
|
||||
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
|
||||
|
||||
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
|
||||
win32_cond->waiter_count++;
|
||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
||||
|
||||
// unlock the external mutex
|
||||
pthread_mutex_unlock(mutex);
|
||||
WaitForSingleObject(win32_cond->semaphore, INFINITE);
|
||||
pthread_mutex_lock(mutex);
|
||||
|
||||
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
|
||||
win32_cond->waiter_count--;
|
||||
last_waiter = !win32_cond->waiter_count && win32_cond->is_broadcast;
|
||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
||||
|
||||
if (last_waiter)
|
||||
SetEvent(win32_cond->waiters_done);
|
||||
|
||||
// lock the external mutex
|
||||
return pthread_mutex_lock(mutex);
|
||||
}
|
||||
|
||||
static void pthread_cond_signal(pthread_cond_t *cond)
|
||||
{
|
||||
win32_cond_t *win32_cond = cond->ptr;
|
||||
int have_waiter;
|
||||
if (cond_signal) {
|
||||
cond_signal(cond);
|
||||
return;
|
||||
@ -199,11 +237,11 @@ static void pthread_cond_signal(pthread_cond_t *cond)
|
||||
|
||||
/* non-native condition variables */
|
||||
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
|
||||
if (win32_cond->waiter_count) {
|
||||
ReleaseSemaphore(win32_cond->semaphore, 1, NULL);
|
||||
win32_cond->waiter_count--;
|
||||
}
|
||||
have_waiter = win32_cond->waiter_count;
|
||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
||||
|
||||
if (have_waiter)
|
||||
ReleaseSemaphore(win32_cond->semaphore, 1, NULL);
|
||||
}
|
||||
|
||||
static void w32thread_init(void)
|
||||
|
@ -335,8 +335,8 @@ static int dc1394_read_packet(AVFormatContext *c, AVPacket *pkt)
|
||||
|
||||
res = dc1394_capture_dequeue(dc1394->camera, DC1394_CAPTURE_POLICY_WAIT, &dc1394->frame);
|
||||
if (res == DC1394_SUCCESS) {
|
||||
dc1394->packet.data = (uint8_t *)(dc1394->frame->image);
|
||||
dc1394->packet.pts = (dc1394->current_frame * 1000000) / (dc1394->frame_rate);
|
||||
dc1394->packet.data = (uint8_t *) dc1394->frame->image;
|
||||
dc1394->packet.pts = dc1394->current_frame * 1000000 / dc1394->frame_rate;
|
||||
res = dc1394->frame->image_bytes;
|
||||
} else {
|
||||
av_log(c, AV_LOG_ERROR, "DMA capture failed\n");
|
||||
|
@ -33,9 +33,11 @@
|
||||
#include "libavutil/file.h"
|
||||
#include "libavutil/eval.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/random_seed.h"
|
||||
#include "libavutil/parseutils.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "libavutil/tree.h"
|
||||
#include "libavutil/lfg.h"
|
||||
#include "avfilter.h"
|
||||
#include "drawutils.h"
|
||||
|
||||
@ -67,6 +69,22 @@ static const char * const var_names[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char *fun2_names[] = {
|
||||
"rand",
|
||||
};
|
||||
|
||||
static double drand(void *opaque, double min, double max)
|
||||
{
|
||||
return min + (max-min) / UINT_MAX * av_lfg_get(opaque);
|
||||
}
|
||||
|
||||
typedef double (*eval_func2)(void *, double a, double b);
|
||||
|
||||
static const eval_func2 fun2[] = {
|
||||
drand,
|
||||
NULL
|
||||
};
|
||||
|
||||
enum var_name {
|
||||
VAR_MAIN_W, VAR_w, VAR_W,
|
||||
VAR_MAIN_H, VAR_h, VAR_H,
|
||||
@ -132,6 +150,10 @@ typedef struct {
|
||||
AVExpr *x_pexpr, *y_pexpr; ///< parsed expressions for x and y
|
||||
int64_t basetime; ///< base pts time in the real world for display
|
||||
double var_values[VAR_VARS_NB];
|
||||
char *d_expr;
|
||||
AVExpr *d_pexpr;
|
||||
int draw; ///< set to zero to prevent drawing
|
||||
AVLFG prng; ///< random
|
||||
} DrawTextContext;
|
||||
|
||||
#define OFFSET(x) offsetof(DrawTextContext, x)
|
||||
@ -151,7 +173,7 @@ static const AVOption drawtext_options[]= {
|
||||
{"shadowy", "set y", OFFSET(shadowy), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX },
|
||||
{"tabsize", "set tab size", OFFSET(tabsize), AV_OPT_TYPE_INT, {.dbl=4}, 0, INT_MAX },
|
||||
{"basetime", "set base time", OFFSET(basetime), AV_OPT_TYPE_INT64, {.dbl=AV_NOPTS_VALUE}, INT64_MIN, INT64_MAX },
|
||||
|
||||
{"draw", "if false do not draw", OFFSET(d_expr), AV_OPT_TYPE_STRING, {.str="1"}, CHAR_MIN, CHAR_MAX },
|
||||
|
||||
/* FT_LOAD_* flags */
|
||||
{"ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), AV_OPT_TYPE_FLAGS, {.dbl=FT_LOAD_DEFAULT|FT_LOAD_RENDER}, 0, INT_MAX, 0, "ft_load_flags" },
|
||||
@ -470,10 +492,15 @@ static int config_input(AVFilterLink *inlink)
|
||||
dtext->var_values[VAR_N] = 0;
|
||||
dtext->var_values[VAR_T] = NAN;
|
||||
|
||||
av_lfg_init(&dtext->prng, av_get_random_seed());
|
||||
|
||||
if ((ret = av_expr_parse(&dtext->x_pexpr, dtext->x_expr, var_names,
|
||||
NULL, NULL, NULL, NULL, 0, ctx)) < 0 ||
|
||||
NULL, NULL, fun2_names, fun2, 0, ctx)) < 0 ||
|
||||
(ret = av_expr_parse(&dtext->y_pexpr, dtext->y_expr, var_names,
|
||||
NULL, NULL, NULL, NULL, 0, ctx)) < 0)
|
||||
NULL, NULL, fun2_names, fun2, 0, ctx)) < 0 ||
|
||||
(ret = av_expr_parse(&dtext->d_pexpr, dtext->d_expr, var_names,
|
||||
NULL, NULL, fun2_names, fun2, 0, ctx)) < 0)
|
||||
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
return 0;
|
||||
@ -761,9 +788,13 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
|
||||
|
||||
dtext->var_values[VAR_LINE_H] = dtext->var_values[VAR_LH] = dtext->max_glyph_h;
|
||||
|
||||
dtext->x = dtext->var_values[VAR_X] = av_expr_eval(dtext->x_pexpr, dtext->var_values, NULL);
|
||||
dtext->y = dtext->var_values[VAR_Y] = av_expr_eval(dtext->y_pexpr, dtext->var_values, NULL);
|
||||
dtext->x = dtext->var_values[VAR_X] = av_expr_eval(dtext->x_pexpr, dtext->var_values, NULL);
|
||||
dtext->x = dtext->var_values[VAR_X] = av_expr_eval(dtext->x_pexpr, dtext->var_values, &dtext->prng);
|
||||
dtext->y = dtext->var_values[VAR_Y] = av_expr_eval(dtext->y_pexpr, dtext->var_values, &dtext->prng);
|
||||
dtext->x = dtext->var_values[VAR_X] = av_expr_eval(dtext->x_pexpr, dtext->var_values, &dtext->prng);
|
||||
dtext->draw = av_expr_eval(dtext->d_pexpr, dtext->var_values, &dtext->prng);
|
||||
|
||||
if(!dtext->draw)
|
||||
return 0;
|
||||
|
||||
dtext->x &= ~((1 << dtext->hsub) - 1);
|
||||
dtext->y &= ~((1 << dtext->vsub) - 1);
|
||||
|
@ -75,6 +75,7 @@ typedef struct RTMPContext {
|
||||
uint8_t flv_header[11]; ///< partial incoming flv packet header
|
||||
int flv_header_bytes; ///< number of initialized bytes in flv_header
|
||||
int nb_invokes; ///< keeps track of invoke messages
|
||||
int create_stream_invoke; ///< invoke id for the create stream command
|
||||
} RTMPContext;
|
||||
|
||||
#define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing
|
||||
@ -115,7 +116,7 @@ static void gen_connect(URLContext *s, RTMPContext *rt, const char *proto,
|
||||
|
||||
ff_url_join(tcurl, sizeof(tcurl), proto, NULL, host, port, "/%s", rt->app);
|
||||
ff_amf_write_string(&p, "connect");
|
||||
ff_amf_write_number(&p, 1.0);
|
||||
ff_amf_write_number(&p, ++rt->nb_invokes);
|
||||
ff_amf_write_object_start(&p);
|
||||
ff_amf_write_field_name(&p, "app");
|
||||
ff_amf_write_string(&p, rt->app);
|
||||
@ -237,6 +238,7 @@ static void gen_create_stream(URLContext *s, RTMPContext *rt)
|
||||
ff_amf_write_string(&p, "createStream");
|
||||
ff_amf_write_number(&p, ++rt->nb_invokes);
|
||||
ff_amf_write_null(&p);
|
||||
rt->create_stream_invoke = rt->nb_invokes;
|
||||
|
||||
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
|
||||
ff_rtmp_packet_destroy(&pkt);
|
||||
@ -257,7 +259,7 @@ static void gen_delete_stream(URLContext *s, RTMPContext *rt)
|
||||
|
||||
p = pkt.data;
|
||||
ff_amf_write_string(&p, "deleteStream");
|
||||
ff_amf_write_number(&p, 0.0);
|
||||
ff_amf_write_number(&p, ++rt->nb_invokes);
|
||||
ff_amf_write_null(&p);
|
||||
ff_amf_write_number(&p, rt->main_channel_id);
|
||||
|
||||
@ -281,7 +283,7 @@ static void gen_play(URLContext *s, RTMPContext *rt)
|
||||
|
||||
p = pkt.data;
|
||||
ff_amf_write_string(&p, "play");
|
||||
ff_amf_write_number(&p, 0.0);
|
||||
ff_amf_write_number(&p, ++rt->nb_invokes);
|
||||
ff_amf_write_null(&p);
|
||||
ff_amf_write_string(&p, rt->playpath);
|
||||
|
||||
@ -315,7 +317,7 @@ static void gen_publish(URLContext *s, RTMPContext *rt)
|
||||
|
||||
p = pkt.data;
|
||||
ff_amf_write_string(&p, "publish");
|
||||
ff_amf_write_number(&p, 0.0);
|
||||
ff_amf_write_number(&p, ++rt->nb_invokes);
|
||||
ff_amf_write_null(&p);
|
||||
ff_amf_write_string(&p, rt->playpath);
|
||||
ff_amf_write_string(&p, "live");
|
||||
@ -614,7 +616,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
|
||||
* releaseStream and FCPublish calls */
|
||||
if (!pkt->data[10]) {
|
||||
int pkt_id = (int) av_int2dbl(AV_RB64(pkt->data + 11));
|
||||
if (pkt_id == 4)
|
||||
if (pkt_id == rt->create_stream_invoke)
|
||||
rt->state = STATE_CONNECTING;
|
||||
}
|
||||
if (rt->state != STATE_CONNECTING)
|
||||
|
@ -2247,7 +2247,6 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
|
||||
pkt.size -= ret;
|
||||
}
|
||||
}
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
/** @name Error flags returned by av_lzo1x_decode
|
||||
* \{ */
|
||||
* @{ */
|
||||
/// end of the input buffer reached before decoding finished
|
||||
#define AV_LZO_INPUT_DEPLETED 1
|
||||
/// decoded data did not fit into output buffer
|
||||
@ -41,7 +41,7 @@
|
||||
#define AV_LZO_INVALID_BACKPTR 4
|
||||
/// a non-specific error in the compressed bitstream
|
||||
#define AV_LZO_ERROR 8
|
||||
/** \} */
|
||||
/** @} */
|
||||
|
||||
#define AV_LZO_INPUT_PADDING 8
|
||||
#define AV_LZO_OUTPUT_PADDING 12
|
||||
|
Loading…
Reference in New Issue
Block a user