Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libav
diff options
context:
space:
mode:
authorPhilip Gladstone <philipjsg@users.sourceforge.net>2002-09-12 06:26:58 +0400
committerPhilip Gladstone <philipjsg@users.sourceforge.net>2002-09-12 06:26:58 +0400
commit75bdb984c7f422232d963facaf4f96887d40530a (patch)
tree019b1b1604ffdd7fd076d085e9a028a0b13f1ee6 /libav
parent208d3ddf961c745b20e19f1568dca3f631856d34 (diff)
Add the transfer of the new parameters from ffmpeg to ffserver and vice-versa
This adds functions to send and receive doubles and also null terminated strings. Originally committed as revision 919 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libav')
-rw-r--r--libav/avio.h7
-rw-r--r--libav/aviobuf.c39
-rw-r--r--libav/ffm.c22
3 files changed, 65 insertions, 3 deletions
diff --git a/libav/avio.h b/libav/avio.h
index 2c13c0377c..be4189b8a3 100644
--- a/libav/avio.h
+++ b/libav/avio.h
@@ -78,7 +78,7 @@ int init_put_byte(ByteIOContext *s,
int (*seek)(void *opaque, offset_t offset, int whence));
void put_byte(ByteIOContext *s, int b);
-void put_buffer(ByteIOContext *s, unsigned char *buf, int size);
+void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
void put_le64(ByteIOContext *s, UINT64 val);
void put_be64(ByteIOContext *s, UINT64 val);
void put_le32(ByteIOContext *s, unsigned int val);
@@ -87,6 +87,9 @@ void put_le16(ByteIOContext *s, unsigned int val);
void put_be16(ByteIOContext *s, unsigned int val);
void put_tag(ByteIOContext *s, char *tag);
+void put_native_double(ByteIOContext *s, double val);
+void put_native_string(ByteIOContext *s, const char *buf);
+
offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
void url_fskip(ByteIOContext *s, offset_t offset);
offset_t url_ftell(ByteIOContext *s);
@@ -105,6 +108,8 @@ unsigned int get_le32(ByteIOContext *s);
UINT64 get_le64(ByteIOContext *s);
unsigned int get_le16(ByteIOContext *s);
+double get_native_double(ByteIOContext *s);
+char *get_native_string(ByteIOContext *s, char *buf, int maxlen);
unsigned int get_be16(ByteIOContext *s);
unsigned int get_be32(ByteIOContext *s);
UINT64 get_be64(ByteIOContext *s);
diff --git a/libav/aviobuf.c b/libav/aviobuf.c
index 6c23088d91..3f0108361b 100644
--- a/libav/aviobuf.c
+++ b/libav/aviobuf.c
@@ -68,7 +68,7 @@ void put_byte(ByteIOContext *s, int b)
flush_buffer(s);
}
-void put_buffer(ByteIOContext *s, unsigned char *buf, int size)
+void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)
{
int len;
@@ -176,6 +176,19 @@ void put_be32(ByteIOContext *s, unsigned int val)
put_byte(s, val);
}
+void put_native_double(ByteIOContext *s, double val)
+{
+ put_buffer(s, (const unsigned char *) &val, sizeof(val));
+}
+
+void put_native_string(ByteIOContext *s, const char *str)
+{
+ if (str)
+ put_buffer(s, (const unsigned char *) str, strlen(str) + 1);
+ else
+ put_byte(s, 0);
+}
+
void put_le64(ByteIOContext *s, UINT64 val)
{
put_le32(s, (UINT32)(val & 0xffffffff));
@@ -326,6 +339,30 @@ unsigned int get_be32(ByteIOContext *s)
return val;
}
+double get_native_double(ByteIOContext *s)
+{
+ double val;
+
+ get_buffer(s, (unsigned char *) &val, sizeof(val));
+
+ return val;
+}
+
+char *get_native_string(ByteIOContext *s, char *buf, int maxlen)
+{
+ int i = 0;
+ char c;
+
+ while ((c = get_byte(s))) {
+ if (i < maxlen-1)
+ buf[i++] = c;
+ }
+
+ buf[i] = 0; /* Ensure null terminated, but may be truncated */
+
+ return buf;
+}
+
UINT64 get_be64(ByteIOContext *s)
{
UINT64 val;
diff --git a/libav/ffm.c b/libav/ffm.c
index 205626fe67..45bfbcb7ce 100644
--- a/libav/ffm.c
+++ b/libav/ffm.c
@@ -166,6 +166,15 @@ static int ffm_write_header(AVFormatContext *s)
put_be16(pb, (int) (codec->qcompress * 10000.0));
put_be16(pb, (int) (codec->qblur * 10000.0));
put_be32(pb, codec->bit_rate_tolerance);
+ put_native_string(pb, codec->rc_eq);
+ put_be32(pb, codec->rc_max_rate);
+ put_be32(pb, codec->rc_min_rate);
+ put_be32(pb, codec->rc_buffer_size);
+ put_native_double(pb, codec->i_quant_factor);
+ put_native_double(pb, codec->b_quant_factor);
+ put_native_double(pb, codec->i_quant_offset);
+ put_native_double(pb, codec->b_quant_offset);
+ put_be32(pb, codec->dct_algo);
break;
case CODEC_TYPE_AUDIO:
put_be32(pb, codec->sample_rate);
@@ -380,6 +389,8 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_be32(pb); /* total bitrate */
/* read each stream */
for(i=0;i<s->nb_streams;i++) {
+ char rc_eq_buf[128];
+
st = av_mallocz(sizeof(AVStream));
if (!st)
goto fail;
@@ -409,6 +420,15 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec->qcompress = get_be16(pb) / 10000.0;
codec->qblur = get_be16(pb) / 10000.0;
codec->bit_rate_tolerance = get_be32(pb);
+ codec->rc_eq = strdup(get_native_string(pb, rc_eq_buf, sizeof(rc_eq_buf)));
+ codec->rc_max_rate = get_be32(pb);
+ codec->rc_min_rate = get_be32(pb);
+ codec->rc_buffer_size = get_be32(pb);
+ codec->i_quant_factor = get_native_double(pb);
+ codec->b_quant_factor = get_native_double(pb);
+ codec->i_quant_offset = get_native_double(pb);
+ codec->b_quant_offset = get_native_double(pb);
+ codec->dct_algo = get_be32(pb);
break;
case CODEC_TYPE_AUDIO:
codec->sample_rate = get_be32(pb);
@@ -416,7 +436,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec->frame_size = get_le16(pb);
break;
default:
- av_abort();
+ goto fail;
}
}