Skip to content

Commit

Permalink
Merge svn changes up to r30798
Browse files Browse the repository at this point in the history
  • Loading branch information
Uoti Urpala committed Mar 10, 2010
2 parents f7cc415 + e9a5e7f commit bc1d0ca
Show file tree
Hide file tree
Showing 32 changed files with 345 additions and 292 deletions.
47 changes: 0 additions & 47 deletions asxparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,53 +34,6 @@

////// List utils

static void
asx_list_add(void* list_ptr,void* entry){
void** list = *(void***)list_ptr;
int c = 0;

if(list != NULL)
for( ; list[c] != NULL; c++) ;

list = realloc(list, sizeof(void*) * (c + 2));

list[c] = entry;
list[c+1] = NULL;

*(void***)list_ptr = list;
}


static void
asx_list_remove(void* list_ptr,void* entry,ASX_FreeFunc free_func) {
void** list = *(void***)list_ptr;
int c,e = -1;

if(list == NULL) return;

for(c = 0 ; list[c] != NULL; c++){
if(list[c] == entry) e = c;
}

if(e == -1) return; // Not found

if(free_func != NULL) free_func(list[e]);

if(c == 1) { // Only one entry, we drop all
free(list);
*(void**)list_ptr = NULL;
return;
}

if(c > e) // If c==e the memmove is not needed
memmove(list+e,list+e+1,(c-e)*sizeof(void*));

list = realloc(list, (c - 1) * sizeof(void*));
list[c-1] = NULL;

*(void***)list_ptr = list;
}

void
asx_list_free(void* list_ptr,ASX_FreeFunc free_func) {
void** ptr = *(void***)list_ptr;
Expand Down
6 changes: 3 additions & 3 deletions cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ cpuid(int func) {
static int64_t
rdtsc(void)
{
uint64_t i;
uint32_t hi, lo;
#define RDTSC ".byte 0x0f, 0x31; "
__asm__ volatile (RDTSC : "=A"(i) : );
return i;
__asm__ volatile (RDTSC : "=a"(lo), "=d"(hi) : );
return (uint64_t) hi << 32 | lo;
}

static const char*
Expand Down
2 changes: 2 additions & 0 deletions input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,8 @@ static int read_cmd(mp_input_fd_t* mp_fd, char** ret)
int l = 0;
// Find the cmd end
mp_fd->buffer[mp_fd->pos] = '\0';
end = strchr(mp_fd->buffer,'\r');
if (end) *end = '\n';
end = strchr(mp_fd->buffer,'\n');
// No cmd end ?
if(!end) {
Expand Down
1 change: 1 addition & 0 deletions input/lirc.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "mp_msg.h"
#include "help_mp.h"
#include "input.h"
#include "lirc.h"

static struct lirc_config *lirc_config;
char *lirc_configfile;
Expand Down
2 changes: 1 addition & 1 deletion libmpcodecs/ae_toolame.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int encode_toolame(audio_encoder_t *encoder, uint8_t *dest, void *src, in
return ret_size;
}

int close_toolame(audio_encoder_t *encoder)
static int close_toolame(audio_encoder_t *encoder)
{
free(encoder->priv);
return 1;
Expand Down
2 changes: 1 addition & 1 deletion libmpcodecs/ae_twolame.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static int encode_twolame(audio_encoder_t *encoder, uint8_t *dest, void *src, in
return ret_size;
}

int close_twolame(audio_encoder_t *encoder)
static int close_twolame(audio_encoder_t *encoder)
{
free(encoder->priv);
return 1;
Expand Down
7 changes: 2 additions & 5 deletions libmpcodecs/ve_x264.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,9 @@ static int encode_frame(struct vf_instance *vf, x264_picture_t *pic_in)
return -1;
}
if(i_size>0) {
int keyframe = (pic_out.i_type == X264_TYPE_IDR) ||
(pic_out.i_type == X264_TYPE_I
&& param.i_frame_reference == 1
&& !param.i_bframe);
int keyframe = pic_out.b_keyframe;
memcpy(mod->mux->buffer, nal->p_payload, i_size);
muxer_write_chunk(mod->mux, i_size, keyframe?0x10:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
muxer_write_chunk(mod->mux, i_size, keyframe?AVIIF_KEYFRAME:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
}
else
++mod->mux->encoder_delay;
Expand Down
109 changes: 55 additions & 54 deletions libmpcodecs/vf_remove_logo.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ typedef struct
* Variables stored here are kept from frame to frame, and separate instances of
* the filter will get their own separate copies.
*/
typedef struct
struct vf_priv_s
{
unsigned int fmt; /* Not exactly sure of the use for this. It came with the example filter I used as a basis for this, and it looks like a lot of stuff will break if I remove it. */
int max_mask_size; /* The largest possible mask size that will be needed with the given filter and corresponding half_size_filter. The half_size_filter can have a larger requirment in some rare (but not degenerate) cases. */
Expand Down Expand Up @@ -264,8 +264,8 @@ static void destroy_masks(vf_instance_t * vf)
int a, b;

/* Load values from the vf->priv struct for faster dereferencing. */
int * * * mask = ((vf_priv_s *)vf->priv)->mask;
int max_mask_size = ((vf_priv_s *)vf->priv)->max_mask_size;
int * * * mask = vf->priv->mask;
int max_mask_size = vf->priv->max_mask_size;

if (mask == NULL)
return; /* Nothing allocated, so return before we segfault. */
Expand All @@ -282,7 +282,7 @@ static void destroy_masks(vf_instance_t * vf)
free(mask); /* Free the array of pointers pointing to the masks. */

/* Set the pointer to NULL, so that any duplicate calls to this function will not cause a crash. */
((vf_priv_s *)vf->priv)->mask = NULL;
vf->priv->mask = NULL;

return;
}
Expand All @@ -301,8 +301,8 @@ static void initialize_masks(vf_instance_t * vf)
int a, b, c;

/* Load values from the vf->priv struct for faster dereferencing. */
int * * * mask = ((vf_priv_s *)vf->priv)->mask;
int max_mask_size = ((vf_priv_s *)vf->priv)->max_mask_size; /* This tells us how many masks we'll need to generate. */
int * * * mask = vf->priv->mask;
int max_mask_size = vf->priv->max_mask_size; /* This tells us how many masks we'll need to generate. */

/* Create a circular mask for each size up to max_mask_size. When the filter is applied, the mask size is
determined on a pixel by pixel basis, with pixels nearer the edge of the logo getting smaller mask sizes. */
Expand All @@ -324,7 +324,7 @@ static void initialize_masks(vf_instance_t * vf)
}

/* Store values back to vf->priv so they aren't lost after the function returns. */
((vf_priv_s *)vf->priv)->mask = mask;
vf->priv->mask = mask;

return;
}
Expand Down Expand Up @@ -404,7 +404,7 @@ static void convert_mask_to_strength_mask(vf_instance_t * vf, pgm_structure * ma
max_mask_size = current_pass + 1; /* As a side-effect, we now know the maximum mask size, which we'll use to generate our masks. */
max_mask_size = apply_mask_fudge_factor(max_mask_size); /* Apply the fudge factor to this number too, since we must
ensure that enough masks are generated. */
((vf_priv_s *)vf->priv)->max_mask_size = max_mask_size; /* Commit the newly calculated max_mask_size to the vf->priv struct. */
vf->priv->max_mask_size = max_mask_size; /* Commit the newly calculated max_mask_size to the vf->priv struct. */

return;
}
Expand All @@ -430,7 +430,7 @@ static void get_blur(const vf_instance_t * const vf, unsigned int * const value_
{
int mask_size; /* Mask size tells how large a circle to use. The radius is about (slightly larger than) mask size. */
/* Get values from vf->priv for faster dereferencing. */
int * * * mask = ((vf_priv_s *)vf->priv)->mask;
int * * * mask = vf->priv->mask;

int start_posx, start_posy, end_posx, end_posy;
int i, j;
Expand Down Expand Up @@ -662,7 +662,7 @@ static pgm_structure * generate_half_size_image(vf_instance_t * vf, pgm_structur
max_mask_size = current_pass + 1; /* As a side-effect, we now know the maximum mask size, which we'll use to generate our masks. */
max_mask_size = apply_mask_fudge_factor(max_mask_size);
/* Commit the newly calculated max_mask_size to the vf->priv struct. */
((vf_priv_s *)vf->priv)->max_mask_size = max(max_mask_size, ((vf_priv_s *)vf->priv)->max_mask_size);
vf->priv->max_mask_size = max(max_mask_size, vf->priv->max_mask_size);

return new_pgm;
}
Expand All @@ -685,10 +685,10 @@ static unsigned int find_best(struct vf_instance* vf){
*/
static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt)
{
if(!(((vf_priv_s *)vf->priv)->fmt=find_best(vf)))
if(!(vf->priv->fmt=find_best(vf)))
return 0;
else
return vf_next_config(vf,width,height,d_width,d_height,flags,((vf_priv_s *)vf->priv)->fmt);
return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
}

/**
Expand Down Expand Up @@ -767,35 +767,35 @@ static void convert_yv12(const vf_instance_t * const vf, const char * const sour
static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;

dmpi=vf_get_image(vf->next,((vf_priv_s *)vf->priv)->fmt,
dmpi=vf_get_image(vf->next,vf->priv->fmt,
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
mpi->w, mpi->h);

/* Check to make sure that the filter image and the video stream are the same size. */
if ((((vf_priv_s *)vf->priv)->filter->width != mpi->w) || (((vf_priv_s *)vf->priv)->filter->height != mpi->h))
if (vf->priv->filter->width != mpi->w || vf->priv->filter->height != mpi->h)
{
mp_msg(MSGT_VFILTER,MSGL_ERR, "Filter image and video stream are not of the same size. (Filter: %d x %d, Stream: %d x %d)\n",
((vf_priv_s *)vf->priv)->filter->width, ((vf_priv_s *)vf->priv)->filter->height, mpi->w, mpi->h);
vf->priv->filter->width, vf->priv->filter->height, mpi->w, mpi->h);
return 0;
}

switch(dmpi->imgfmt){
case IMGFMT_YV12:
convert_yv12(vf, mpi->planes[0], mpi->stride[0], mpi, mpi->w, mpi->h,
dmpi->planes[0], dmpi->stride[0],
mpi->flags & MP_IMGFLAG_DIRECT, ((vf_priv_s *)vf->priv)->filter, 0,
((vf_priv_s *)vf->priv)->bounding_rectangle_posx1, ((vf_priv_s *)vf->priv)->bounding_rectangle_posy1,
((vf_priv_s *)vf->priv)->bounding_rectangle_posx2, ((vf_priv_s *)vf->priv)->bounding_rectangle_posy2);
mpi->flags & MP_IMGFLAG_DIRECT, vf->priv->filter, 0,
vf->priv->bounding_rectangle_posx1, vf->priv->bounding_rectangle_posy1,
vf->priv->bounding_rectangle_posx2, vf->priv->bounding_rectangle_posy2);
convert_yv12(vf, mpi->planes[1], mpi->stride[1], mpi, mpi->w / 2, mpi->h / 2,
dmpi->planes[1], dmpi->stride[1],
mpi->flags & MP_IMGFLAG_DIRECT, ((vf_priv_s *)vf->priv)->half_size_filter, 1,
((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posx1, ((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posy1,
((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posx2, ((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posy2);
mpi->flags & MP_IMGFLAG_DIRECT, vf->priv->half_size_filter, 1,
vf->priv->bounding_rectangle_half_size_posx1, vf->priv->bounding_rectangle_half_size_posy1,
vf->priv->bounding_rectangle_half_size_posx2, vf->priv->bounding_rectangle_half_size_posy2);
convert_yv12(vf, mpi->planes[2], mpi->stride[2], mpi, mpi->w / 2, mpi->h / 2,
dmpi->planes[2], dmpi->stride[2],
mpi->flags & MP_IMGFLAG_DIRECT, ((vf_priv_s *)vf->priv)->half_size_filter, 2,
((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posx1, ((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posy1,
((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posx2, ((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posy2);
mpi->flags & MP_IMGFLAG_DIRECT, vf->priv->half_size_filter, 2,
vf->priv->bounding_rectangle_half_size_posx1, vf->priv->bounding_rectangle_half_size_posy1,
vf->priv->bounding_rectangle_half_size_posx2, vf->priv->bounding_rectangle_half_size_posy2);
break;

default:
Expand All @@ -819,6 +819,24 @@ static int query_format(struct vf_instance * vf, unsigned int fmt)
return 0;
}

/**
* \brief Frees memory that our filter allocated.
*
* This is called at exit-time.
*/
static void uninit(vf_instance_t *vf)
{
/* Destroy our masks and images. */
destroy_pgm(vf->priv->filter);
destroy_pgm(vf->priv->half_size_filter);
destroy_masks(vf);

/* Destroy our private structure that had been used to store those masks and images. */
free(vf->priv);

return;
}

/**
* \brief Initializes our filter.
*
Expand All @@ -831,65 +849,48 @@ static int query_format(struct vf_instance * vf, unsigned int fmt)
static int vf_open(vf_instance_t *vf, char *args)
{
vf->priv = safe_malloc(sizeof(vf_priv_s));
vf->uninit = uninit;

/* Load our filter image. */
if (args)
((vf_priv_s *)vf->priv)->filter = load_pgm(args);
vf->priv->filter = load_pgm(args);
else
{
mp_msg(MSGT_VFILTER, MSGL_ERR, "[vf]remove_logo usage: remove_logo=/path/to/filter_image_file.pgm\n");
free(vf->priv);
return 0;
}

if (((vf_priv_s *)vf->priv)->filter == NULL)
if (vf->priv->filter == NULL)
{
/* Error message was displayed by load_pgm(). */
free(vf->priv);
return 0;
}

/* Create the scaled down filter image for the chroma planes. */
convert_mask_to_strength_mask(vf, ((vf_priv_s *)vf->priv)->filter);
((vf_priv_s *)vf->priv)->half_size_filter = generate_half_size_image(vf, ((vf_priv_s *)vf->priv)->filter);
convert_mask_to_strength_mask(vf, vf->priv->filter);
vf->priv->half_size_filter = generate_half_size_image(vf, vf->priv->filter);

/* Now that we know how many masks we need (the info is in vf), we can generate the masks. */
initialize_masks(vf);

/* Calculate our bounding rectangles, which determine in what region the logo resides for faster processing. */
calculate_bounding_rectangle(&((vf_priv_s *)vf->priv)->bounding_rectangle_posx1, &((vf_priv_s *)vf->priv)->bounding_rectangle_posy1,
&((vf_priv_s *)vf->priv)->bounding_rectangle_posx2, &((vf_priv_s *)vf->priv)->bounding_rectangle_posy2,
((vf_priv_s *)vf->priv)->filter);
calculate_bounding_rectangle(&((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posx1,
&((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posy1,
&((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posx2,
&((vf_priv_s *)vf->priv)->bounding_rectangle_half_size_posy2,
((vf_priv_s *)vf->priv)->half_size_filter);
calculate_bounding_rectangle(&vf->priv->bounding_rectangle_posx1, &vf->priv->bounding_rectangle_posy1,
&vf->priv->bounding_rectangle_posx2, &vf->priv->bounding_rectangle_posy2,
vf->priv->filter);
calculate_bounding_rectangle(&vf->priv->bounding_rectangle_half_size_posx1,
&vf->priv->bounding_rectangle_half_size_posy1,
&vf->priv->bounding_rectangle_half_size_posx2,
&vf->priv->bounding_rectangle_half_size_posy2,
vf->priv->half_size_filter);

vf->config=config;
vf->put_image=put_image;
vf->query_format=query_format;
return 1;
}

/**
* \brief Frees memory that our filter allocated.
*
* This is called at exit-time.
*/
static void uninit(vf_instance_t * vf)
{
/* Destroy our masks and images. */
destroy_pgm(((vf_priv_s *)vf->priv)->filter);
destroy_pgm(((vf_priv_s *)vf->priv)->half_size_filter);
destroy_masks(vf);

/* Destroy our private structure that had been used to store those masks and images. */
free(vf->priv);

return;
}

/**
* \brief Meta data about our filter.
*/
Expand Down
6 changes: 0 additions & 6 deletions libmpdemux/demux_rtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@

#include <stdlib.h>
#include <stdio.h>

#ifndef STREAM_H
#include "stream/stream.h"
#endif
#ifndef DEMUXER_H
#include "demuxer.h"
#endif

// Open a RTP demuxer (which was initiated either from a SDP file,
// or from a RTSP URL):
Expand Down
5 changes: 0 additions & 5 deletions libmpdemux/demux_rtp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
#include <stdlib.h>

extern "C" {
#ifndef STREAM_H
#include "stream/stream.h"
#endif
#ifndef DEMUXER_H
#include "demuxer.h"
#endif
#ifdef CONFIG_LIBAVCODEC
#include "libavcodec/avcodec.h"
#endif
Expand Down
Loading

0 comments on commit bc1d0ca

Please sign in to comment.