Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
8547ffaa
Commit
8547ffaa
authored
Mar 11, 2004
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* stream_out: sout_buffer_t -> block_t.
parent
298f0e46
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
223 additions
and
286 deletions
+223
-286
modules/stream_out/display.c
modules/stream_out/display.c
+25
-27
modules/stream_out/dummy.c
modules/stream_out/dummy.c
+4
-13
modules/stream_out/duplicate.c
modules/stream_out/duplicate.c
+16
-15
modules/stream_out/es.c
modules/stream_out/es.c
+3
-6
modules/stream_out/gather.c
modules/stream_out/gather.c
+3
-3
modules/stream_out/rtp.c
modules/stream_out/rtp.c
+70
-73
modules/stream_out/standard.c
modules/stream_out/standard.c
+3
-6
modules/stream_out/transcode.c
modules/stream_out/transcode.c
+52
-99
modules/stream_out/transrate/frame.c
modules/stream_out/transrate/frame.c
+23
-23
modules/stream_out/transrate/transrate.c
modules/stream_out/transrate/transrate.c
+21
-18
modules/stream_out/transrate/transrate.h
modules/stream_out/transrate/transrate.h
+3
-3
No files found.
modules/stream_out/display.c
View file @
8547ffaa
...
...
@@ -31,21 +31,12 @@
#include <vlc/input.h>
#include <vlc/sout.h>
#include "codecs.h"
/*****************************************************************************
*
Exported prototypes
*
Module descriptor
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_description
(
_
(
"Display stream output"
)
);
set_capability
(
"sout stream"
,
50
);
...
...
@@ -53,6 +44,14 @@ vlc_module_begin();
set_callbacks
(
Open
,
Close
);
vlc_module_end
();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block_t
*
);
struct
sout_stream_sys_t
{
input_thread_t
*
p_input
;
...
...
@@ -175,32 +174,31 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
}
static
int
Send
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
while
(
p_buffer
)
{
sout_buffer_t
*
p_next
;
block_t
*
p_block
;
block_t
*
p_next
=
p_buffer
->
p_next
;
p_buffer
->
p_next
=
NULL
;
if
(
id
->
p_es
->
p_dec
&&
p_buffer
->
i_size
>
0
&&
(
p_block
=
block_New
(
p_stream
,
p_buffer
->
i_size
))
)
if
(
id
->
p_es
->
p_dec
&&
p_buffer
->
i_buffer
>
0
)
{
p_block
->
i_dts
=
p_buffer
->
i_dts
<=
0
?
0
:
p_buffer
->
i_dts
+
p_sys
->
i_delay
;
p_block
->
i_pts
=
p_buffer
->
i_pts
<=
0
?
0
:
p_buffer
->
i_pts
+
p_sys
->
i_delay
;
if
(
p_buffer
->
i_dts
<=
0
)
p_buffer
->
i_dts
=
0
;
else
p_buffer
->
i_dts
+=
p_sys
->
i_delay
;
p_stream
->
p_vlc
->
pf_memcpy
(
p_block
->
p_buffer
,
p_buffer
->
p_buffer
,
p_buffer
->
i_size
);
if
(
p_buffer
->
i_pts
<=
0
)
p_buffer
->
i_pts
=
0
;
else
p_buffer
->
i_pts
+=
p_sys
->
i_delay
;
input_DecodeBlock
(
id
->
p_es
->
p_dec
,
p_b
lock
);
input_DecodeBlock
(
id
->
p_es
->
p_dec
,
p_b
uffer
);
}
/* *** go to next buffer *** */
p_next
=
p_buffer
->
p_next
;
sout_BufferDelete
(
p_stream
->
p_sout
,
p_buffer
);
p_buffer
=
p_next
;
}
...
...
modules/stream_out/dummy.c
View file @
8547ffaa
...
...
@@ -2,7 +2,7 @@
* dummy.c: dummy stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
* $Id
: dummy.c,v 1.4 2004/01/25 14:34:25 gbazin Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -38,7 +38,7 @@ static void Close ( vlc_object_t * );
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
/*****************************************************************************
* Module descriptor
...
...
@@ -99,18 +99,9 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
}
static
int
Send
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_buffer_t
*
p_next
;
while
(
p_buffer
)
{
p_next
=
p_buffer
->
p_next
;
sout_BufferDelete
(
p_stream
->
p_sout
,
p_buffer
);
p_buffer
=
p_next
;
}
block_ChainRelease
(
p_buffer
);
return
VLC_SUCCESS
;
}
modules/stream_out/duplicate.c
View file @
8547ffaa
...
...
@@ -2,7 +2,7 @@
* duplicate.c: duplicate stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
* $Id
: duplicate.c,v 1.12 2004/01/25 14:34:25 gbazin Exp
$
* $Id$
*
* Author: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -31,19 +31,11 @@
#include <vlc/sout.h>
/*****************************************************************************
*
Exported prototypes
*
Module descriptor
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_description
(
_
(
"Duplicate stream output"
)
);
set_capability
(
"sout stream"
,
50
);
...
...
@@ -52,6 +44,15 @@ vlc_module_begin();
set_callbacks
(
Open
,
Close
);
vlc_module_end
();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block_t
*
);
struct
sout_stream_sys_t
{
int
i_nb_streams
;
...
...
@@ -242,7 +243,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
* Send:
*****************************************************************************/
static
int
Send
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
sout_stream_t
*
p_dup_stream
;
...
...
@@ -251,18 +252,18 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
/* Loop through the linked list of buffers */
while
(
p_buffer
)
{
sout_buffer
_t
*
p_next
=
p_buffer
->
p_next
;
block
_t
*
p_next
=
p_buffer
->
p_next
;
p_buffer
->
p_next
=
NULL
;
for
(
i_stream
=
0
;
i_stream
<
p_sys
->
i_nb_streams
-
1
;
i_stream
++
)
{
sout_buffer
_t
*
p_dup
;
block
_t
*
p_dup
;
p_dup_stream
=
p_sys
->
pp_streams
[
i_stream
];
if
(
id
->
pp_ids
[
i_stream
]
)
{
p_dup
=
sout_BufferDuplicate
(
p_stream
->
p_sout
,
p_buffer
);
p_dup
=
block_Duplicate
(
p_buffer
);
p_dup_stream
->
pf_send
(
p_dup_stream
,
id
->
pp_ids
[
i_stream
],
p_dup
);
...
...
@@ -277,7 +278,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
}
else
{
sout_BufferDelete
(
p_stream
->
p_sout
,
p_buffer
);
block_Release
(
p_buffer
);
}
p_buffer
=
p_next
;
...
...
modules/stream_out/es.c
View file @
8547ffaa
...
...
@@ -2,7 +2,7 @@
* es.c: Elementary stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
* $Id
: es.c,v 1.5 2004/01/25 14:34:25 gbazin Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -40,7 +40,7 @@ static void Close ( vlc_object_t * );
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
/*****************************************************************************
* Module descriptor
...
...
@@ -288,9 +288,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
return
(
NULL
);
}
/* XXX beurk */
p_sout
->
i_preheader
=
__MAX
(
p_sout
->
i_preheader
,
p_mux
->
i_preheader
);
id
=
malloc
(
sizeof
(
sout_stream_id_t
)
);
id
->
p_mux
=
p_mux
;
id
->
p_input
=
sout_MuxAddStream
(
p_mux
,
p_fmt
);
...
...
@@ -320,7 +317,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
}
static
int
Send
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_MuxSendBuffer
(
id
->
p_mux
,
id
->
p_input
,
p_buffer
);
...
...
modules/stream_out/gather.c
View file @
8547ffaa
...
...
@@ -2,7 +2,7 @@
* gather.c: gathering stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
* $Id
: gather.c,v 1.3 2004/01/25 14:34:25 gbazin Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -49,7 +49,7 @@ vlc_module_end();
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
block
_t
*
);
struct
sout_stream_id_t
{
...
...
@@ -187,7 +187,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
* Send:
*****************************************************************************/
static
int
Send
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
p_buffer
)
sout_stream_id_t
*
id
,
block
_t
*
p_buffer
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
...
...
modules/stream_out/rtp.c
View file @
8547ffaa
...
...
@@ -52,7 +52,7 @@ vlc_module_end();
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
block
_t
*
);
struct
sout_stream_sys_t
{
...
...
@@ -87,7 +87,7 @@ struct sout_stream_sys_t
uint16_t
i_sequence
;
uint32_t
i_timestamp_start
;
uint8_t
ssrc
[
4
];
sout_buffer
_t
*
packet
;
block
_t
*
packet
;
/* */
int
i_es
;
...
...
@@ -95,7 +95,7 @@ struct sout_stream_sys_t
};
typedef
int
(
*
pf_rtp_packetizer_t
)(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
block
_t
*
);
struct
sout_stream_id_t
{
...
...
@@ -125,7 +125,7 @@ struct sout_stream_id_t
httpd_url_t
*
p_rtsp_url
;
};
static
int
AccessOutGrabberWrite
(
sout_access_out_t
*
,
sout_buffer
_t
*
);
static
int
AccessOutGrabberWrite
(
sout_access_out_t
*
,
block
_t
*
);
static
int
HttpSetup
(
sout_stream_t
*
p_stream
,
vlc_url_t
*
);
static
int
RtspSetup
(
sout_stream_t
*
p_stream
,
vlc_url_t
*
);
...
...
@@ -274,8 +274,6 @@ static int Open( vlc_object_t *p_this )
free
(
p_sys
);
return
VLC_EGENERIC
;
}
p_sout
->
i_preheader
=
__MAX
(
p_sout
->
i_preheader
,
p_sys
->
p_mux
->
i_preheader
);
/* create the SDP only once */
p_sys
->
psz_sdp
=
...
...
@@ -362,7 +360,7 @@ static void Close( vlc_object_t * p_this )
sout_AccessOutDelete
(
p_sys
->
p_grab
);
if
(
p_sys
->
packet
)
{
sout_BufferDelete
(
p_stream
->
p_sout
,
p_sys
->
packet
);
block_Release
(
p_sys
->
packet
);
}
}
...
...
@@ -475,13 +473,13 @@ static char *SDPGenerate( sout_stream_t *p_stream, char *psz_destination, vlc_bo
/*****************************************************************************
*
*****************************************************************************/
static
int
rtp_packetize_l16
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
rtp_packetize_l8
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
rtp_packetize_mpa
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
rtp_packetize_mpv
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
rtp_packetize_ac3
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
rtp_packetize_split
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
rtp_packetize_mp4a
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
rtp_packetize_l16
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
static
int
rtp_packetize_l8
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
static
int
rtp_packetize_mpa
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
static
int
rtp_packetize_mpv
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
static
int
rtp_packetize_ac3
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
static
int
rtp_packetize_split
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
static
int
rtp_packetize_mp4a
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
static
void
sprintf_hexa
(
char
*
s
,
uint8_t
*
p_data
,
int
i_data
)
{
...
...
@@ -728,9 +726,9 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
}
static
int
Send
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_buffer
_t
*
p_next
;
block
_t
*
p_next
;
if
(
p_stream
->
p_sys
->
p_mux
)
{
...
...
@@ -745,7 +743,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
{
break
;
}
sout_BufferDelete
(
p_stream
->
p_sout
,
p_buffer
);
block_Release
(
p_buffer
);
p_buffer
=
p_next
;
}
}
...
...
@@ -754,7 +752,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
static
int
AccessOutGrabberWriteBuffer
(
sout_stream_t
*
p_stream
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
...
...
@@ -762,10 +760,10 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
uint32_t
i_timestamp
=
i_dts
*
9
/
100
;
uint8_t
*
p_data
=
p_buffer
->
p_buffer
;
unsigned
int
i_data
=
p_buffer
->
i_
size
;
unsigned
int
i_data
=
p_buffer
->
i_
buffer
;
unsigned
int
i_max
=
p_sys
->
i_mtu
-
12
;
int
i_packet
=
(
p_buffer
->
i_
size
+
i_max
-
1
)
/
i_max
;
int
i_packet
=
(
p_buffer
->
i_
buffer
+
i_max
-
1
)
/
i_max
;
while
(
i_data
>
0
)
{
...
...
@@ -773,7 +771,7 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
/* output complete packet */
if
(
p_sys
->
packet
&&
p_sys
->
packet
->
i_
size
+
i_data
>
i_max
)
p_sys
->
packet
->
i_
buffer
+
i_data
>
i_max
)
{
sout_AccessOutWrite
(
p_sys
->
p_access
,
p_sys
->
packet
);
p_sys
->
packet
=
NULL
;
...
...
@@ -782,7 +780,7 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
if
(
p_sys
->
packet
==
NULL
)
{
/* allocate a new packet */
p_sys
->
packet
=
sout_BufferNew
(
p_stream
->
p_sout
,
p_sys
->
i_mtu
);
p_sys
->
packet
=
block_New
(
p_stream
,
p_sys
->
i_mtu
);
p_sys
->
packet
->
p_buffer
[
0
]
=
0x80
;
p_sys
->
packet
->
p_buffer
[
1
]
=
p_sys
->
i_payload_type
;
p_sys
->
packet
->
p_buffer
[
2
]
=
(
p_sys
->
i_sequence
>>
8
)
&
0xff
;
...
...
@@ -795,7 +793,7 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
p_sys
->
packet
->
p_buffer
[
9
]
=
p_sys
->
ssrc
[
1
];
p_sys
->
packet
->
p_buffer
[
10
]
=
p_sys
->
ssrc
[
2
];
p_sys
->
packet
->
p_buffer
[
11
]
=
p_sys
->
ssrc
[
3
];
p_sys
->
packet
->
i_
size
=
12
;
p_sys
->
packet
->
i_
buffer
=
12
;
p_sys
->
packet
->
i_dts
=
i_dts
;
p_sys
->
packet
->
i_length
=
p_buffer
->
i_length
/
i_packet
;
...
...
@@ -804,13 +802,12 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
p_sys
->
i_sequence
++
;
}
i_size
=
__MIN
(
i_data
,
p_sys
->
i_mtu
-
p_sys
->
packet
->
i_
size
);
i_size
=
__MIN
(
i_data
,
p_sys
->
i_mtu
-
p_sys
->
packet
->
i_
buffer
);
memcpy
(
&
p_sys
->
packet
->
p_buffer
[
p_sys
->
packet
->
i_size
],
p_data
,
i_size
);
memcpy
(
&
p_sys
->
packet
->
p_buffer
[
p_sys
->
packet
->
i_buffer
],
p_data
,
i_size
);
p_sys
->
packet
->
i_
size
+=
i_size
;
p_sys
->
packet
->
i_
buffer
+=
i_size
;
p_data
+=
i_size
;
i_data
-=
i_size
;
}
...
...
@@ -819,20 +816,20 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
}
static
int
AccessOutGrabberWrite
(
sout_access_out_t
*
p_access
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_stream_t
*
p_stream
=
(
sout_stream_t
*
)
p_access
->
p_sys
;
//fprintf( stderr, "received buffer size=%d\n", p_buffer->i_
size
);
//fprintf( stderr, "received buffer size=%d\n", p_buffer->i_
buffer
);
//
while
(
p_buffer
)
{
sout_buffer
_t
*
p_next
;
block
_t
*
p_next
;
AccessOutGrabberWriteBuffer
(
p_stream
,
p_buffer
);
p_next
=
p_buffer
->
p_next
;
sout_BufferDelete
(
p_access
->
p_sout
,
p_buffer
);
block_Release
(
p_buffer
);
p_buffer
=
p_next
;
}
...
...
@@ -1032,7 +1029,7 @@ static int RtspCallback( httpd_callback_sys_t *p_args,
/****************************************************************************
* rtp_packetize_*:
****************************************************************************/
static
void
rtp_packetize_common
(
sout_stream_id_t
*
id
,
sout_buffer
_t
*
out
,
static
void
rtp_packetize_common
(
sout_stream_id_t
*
id
,
block
_t
*
out
,
int
b_marker
,
int64_t
i_pts
)
{
uint32_t
i_timestamp
=
i_pts
*
(
int64_t
)
id
->
i_clock_rate
/
I64C
(
1000000
);
...
...
@@ -1051,24 +1048,24 @@ static void rtp_packetize_common( sout_stream_id_t *id, sout_buffer_t *out,
out
->
p_buffer
[
10
]
=
id
->
ssrc
[
2
];
out
->
p_buffer
[
11
]
=
id
->
ssrc
[
3
];
out
->
i_
size
=
12
;
out
->
i_
buffer
=
12
;
id
->
i_sequence
++
;
}
static
int
rtp_packetize_mpa
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
in
)
block
_t
*
in
)
{
int
i_max
=
id
->
i_mtu
-
12
-
4
;
/* payload max in one packet */
int
i_count
=
(
in
->
i_
size
+
i_max
-
1
)
/
i_max
;
int
i_count
=
(
in
->
i_
buffer
+
i_max
-
1
)
/
i_max
;
uint8_t
*
p_data
=
in
->
p_buffer
;
int
i_data
=
in
->
i_
size
;
int
i_data
=
in
->
i_
buffer
;
int
i
;
for
(
i
=
0
;
i
<
i_count
;
i
++
)
{
int
i_payload
=
__MIN
(
i_max
,
i_data
);
sout_buffer_t
*
out
=
sout_BufferNew
(
p_stream
->
p_sout
,
16
+
i_payload
);
block_t
*
out
=
block_New
(
p_stream
,
16
+
i_payload
);
/* rtp common header */
rtp_packetize_common
(
id
,
out
,
(
i
==
i_count
-
1
)
?
1
:
0
,
in
->
i_pts
);
...
...
@@ -1080,7 +1077,7 @@ static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id,
out
->
p_buffer
[
15
]
=
(
(
i
*
i_max
)
)
&
0xff
;
memcpy
(
&
out
->
p_buffer
[
16
],
p_data
,
i_payload
);
out
->
i_
size
=
16
+
i_payload
;
out
->
i_
buffer
=
16
+
i_payload
;
out
->
i_dts
=
in
->
i_dts
+
i
*
in
->
i_length
/
i_count
;
out
->
i_length
=
in
->
i_length
/
i_count
;
...
...
@@ -1095,13 +1092,13 @@ static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id,
/* rfc2250 */
static
int
rtp_packetize_mpv
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
in
)
block
_t
*
in
)
{
int
i_max
=
id
->
i_mtu
-
12
-
4
;
/* payload max in one packet */
int
i_count
=
(
in
->
i_
size
+
i_max
-
1
)
/
i_max
;
int
i_count
=
(
in
->
i_
buffer
+
i_max
-
1
)
/
i_max
;
uint8_t
*
p_data
=
in
->
p_buffer
;
int
i_data
=
in
->
i_
size
;
int
i_data
=
in
->
i_
buffer
;
int
i
;
int
b_sequence_start
=
0
;
int
i_temporal_ref
=
0
;
...
...
@@ -1110,10 +1107,10 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
int
b_start_slice
=
0
;
/* preparse this packet to get some info */
if
(
in
->
i_
size
>
4
)
if
(
in
->
i_
buffer
>
4
)
{
uint8_t
*
p
=
p_data
;
int
i_rest
=
in
->
i_
size
;
int
i_rest
=
in
->
i_
buffer
;
for
(
;;
)
{
...
...
@@ -1163,7 +1160,7 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
for
(
i
=
0
;
i
<
i_count
;
i
++
)
{
int
i_payload
=
__MIN
(
i_max
,
i_data
);
sout_buffer_t
*
out
=
sout_BufferNew
(
p_stream
->
p_sout
,
block_t
*
out
=
block_New
(
p_stream
,
16
+
i_payload
);
uint32_t
h
=
(
i_temporal_ref
<<
16
)
|
(
b_sequence_start
<<
13
)
|
...
...
@@ -1184,7 +1181,7 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
memcpy
(
&
out
->
p_buffer
[
16
],
p_data
,
i_payload
);
out
->
i_
size
=
16
+
i_payload
;
out
->
i_
buffer
=
16
+
i_payload
;
out
->
i_dts
=
in
->
i_dts
+
i
*
in
->
i_length
/
i_count
;
out
->
i_length
=
in
->
i_length
/
i_count
;
...
...
@@ -1197,19 +1194,19 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
return
VLC_SUCCESS
;
}
static
int
rtp_packetize_ac3
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
in
)
block
_t
*
in
)
{
int
i_max
=
id
->
i_mtu
-
12
-
2
;
/* payload max in one packet */
int
i_count
=
(
in
->
i_
size
+
i_max
-
1
)
/
i_max
;
int
i_count
=
(
in
->
i_
buffer
+
i_max
-
1
)
/
i_max
;
uint8_t
*
p_data
=
in
->
p_buffer
;
int
i_data
=
in
->
i_
size
;
int
i_data
=
in
->
i_
buffer
;
int
i
;
for
(
i
=
0
;
i
<
i_count
;
i
++
)
{
int
i_payload
=
__MIN
(
i_max
,
i_data
);
sout_buffer_t
*
out
=
sout_BufferNew
(
p_stream
->
p_sout
,
14
+
i_payload
);
block_t
*
out
=
block_New
(
p_stream
,
14
+
i_payload
);
/* rtp common header */
rtp_packetize_common
(
id
,
out
,
(
i
==
i_count
-
1
)
?
1
:
0
,
in
->
i_pts
);
...
...
@@ -1220,7 +1217,7 @@ static int rtp_packetize_ac3( sout_stream_t *p_stream, sout_stream_id_t *id,
/* data */
memcpy
(
&
out
->
p_buffer
[
14
],
p_data
,
i_payload
);
out
->
i_
size
=
14
+
i_payload
;
out
->
i_
buffer
=
14
+
i_payload
;
out
->
i_dts
=
in
->
i_dts
+
i
*
in
->
i_length
/
i_count
;
out
->
i_length
=
in
->
i_length
/
i_count
;
...
...
@@ -1234,26 +1231,26 @@ static int rtp_packetize_ac3( sout_stream_t *p_stream, sout_stream_id_t *id,
}
static
int
rtp_packetize_split
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
in
)
block
_t
*
in
)
{
int
i_max
=
id
->
i_mtu
-
12
;
/* payload max in one packet */
int
i_count
=
(
in
->
i_
size
+
i_max
-
1
)
/
i_max
;
int
i_count
=
(
in
->
i_
buffer
+
i_max
-
1
)
/
i_max
;
uint8_t
*
p_data
=
in
->
p_buffer
;
int
i_data
=
in
->
i_
size
;
int
i_data
=
in
->
i_
buffer
;
int
i
;
for
(
i
=
0
;
i
<
i_count
;
i
++
)
{
int
i_payload
=
__MIN
(
i_max
,
i_data
);
sout_buffer_t
*
out
=
sout_BufferNew
(
p_stream
->
p_sout
,
12
+
i_payload
);
block_t
*
out
=
block_New
(
p_stream
,
12
+
i_payload
);
/* rtp common header */
rtp_packetize_common
(
id
,
out
,
((
i
==
i_count
-
1
)
?
1
:
0
),
(
in
->
i_pts
>
0
?
in
->
i_pts
:
in
->
i_dts
)
);
memcpy
(
&
out
->
p_buffer
[
12
],
p_data
,
i_payload
);
out
->
i_
size
=
12
+
i_payload
;
out
->
i_
buffer
=
12
+
i_payload
;
out
->
i_dts
=
in
->
i_dts
+
i
*
in
->
i_length
/
i_count
;
out
->
i_length
=
in
->
i_length
/
i_count
;
...
...
@@ -1267,26 +1264,26 @@ static int rtp_packetize_split( sout_stream_t *p_stream, sout_stream_id_t *id,
}
static
int
rtp_packetize_l16
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
in
)
block
_t
*
in
)
{
int
i_max
=
id
->
i_mtu
-
12
;
/* payload max in one packet */
int
i_count
=
(
in
->
i_
size
+
i_max
-
1
)
/
i_max
;
int
i_count
=
(
in
->
i_
buffer
+
i_max
-
1
)
/
i_max
;
uint8_t
*
p_data
=
in
->
p_buffer
;
int
i_data
=
in
->
i_
size
;
int
i_data
=
in
->
i_
buffer
;
int
i_packet
=
0
;
while
(
i_data
>
0
)
{
int
i_payload
=
(
__MIN
(
i_max
,
i_data
)
/
4
)
*
4
;
sout_buffer_t
*
out
=
sout_BufferNew
(
p_stream
->
p_sout
,
12
+
i_payload
);
block_t
*
out
=
block_New
(
p_stream
,
12
+
i_payload
);
/* rtp common header */
rtp_packetize_common
(
id
,
out
,
0
,
(
in
->
i_pts
>
0
?
in
->
i_pts
:
in
->
i_dts
)
);
memcpy
(
&
out
->
p_buffer
[
12
],
p_data
,
i_payload
);
out
->
i_
size
=
12
+
i_payload
;
out
->
i_
buffer
=
12
+
i_payload
;
out
->
i_dts
=
in
->
i_dts
+
i_packet
*
in
->
i_length
/
i_count
;
out
->
i_length
=
in
->
i_length
/
i_count
;
...
...
@@ -1301,26 +1298,26 @@ static int rtp_packetize_l16( sout_stream_t *p_stream, sout_stream_id_t *id,
}
static
int
rtp_packetize_l8
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
in
)
block
_t
*
in
)
{
int
i_max
=
id
->
i_mtu
-
12
;
/* payload max in one packet */
int
i_count
=
(
in
->
i_
size
+
i_max
-
1
)
/
i_max
;
int
i_count
=
(
in
->
i_
buffer
+
i_max
-
1
)
/
i_max
;
uint8_t
*
p_data
=
in
->
p_buffer
;
int
i_data
=
in
->
i_
size
;
int
i_data
=
in
->
i_
buffer
;
int
i_packet
=
0
;
while
(
i_data
>
0
)
{
int
i_payload
=
(
__MIN
(
i_max
,
i_data
)
/
2
)
*
2
;
sout_buffer_t
*
out
=
sout_BufferNew
(
p_stream
->
p_sout
,
12
+
i_payload
);
block_t
*
out
=
block_New
(
p_stream
,
12
+
i_payload
);
/* rtp common header */
rtp_packetize_common
(
id
,
out
,
0
,
(
in
->
i_pts
>
0
?
in
->
i_pts
:
in
->
i_dts
)
);
memcpy
(
&
out
->
p_buffer
[
12
],
p_data
,
i_payload
);
out
->
i_
size
=
12
+
i_payload
;
out
->
i_
buffer
=
12
+
i_payload
;
out
->
i_dts
=
in
->
i_dts
+
i_packet
*
in
->
i_length
/
i_count
;
out
->
i_length
=
in
->
i_length
/
i_count
;
...
...
@@ -1334,19 +1331,19 @@ static int rtp_packetize_l8( sout_stream_t *p_stream, sout_stream_id_t *id,
return
VLC_SUCCESS
;
}
static
int
rtp_packetize_mp4a
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
in
)
block
_t
*
in
)
{
int
i_max
=
id
->
i_mtu
-
16
;
/* payload max in one packet */
int
i_count
=
(
in
->
i_
size
+
i_max
-
1
)
/
i_max
;
int
i_count
=
(
in
->
i_
buffer
+
i_max
-
1
)
/
i_max
;
uint8_t
*
p_data
=
in
->
p_buffer
;
int
i_data
=
in
->
i_
size
;
int
i_data
=
in
->
i_
buffer
;
int
i
;
for
(
i
=
0
;
i
<
i_count
;
i
++
)
{
int
i_payload
=
__MIN
(
i_max
,
i_data
);
sout_buffer_t
*
out
=
sout_BufferNew
(
p_stream
->
p_sout
,
16
+
i_payload
);
block_t
*
out
=
block_New
(
p_stream
,
16
+
i_payload
);
/* rtp common header */
rtp_packetize_common
(
id
,
out
,
((
i
==
i_count
-
1
)
?
1
:
0
),
...
...
@@ -1356,12 +1353,12 @@ static int rtp_packetize_mp4a( sout_stream_t *p_stream, sout_stream_id_t *id,
out
->
p_buffer
[
12
]
=
0
;
out
->
p_buffer
[
13
]
=
2
*
8
;
/* for each AU length 13 bits + idx 3bits, */
out
->
p_buffer
[
14
]
=
(
in
->
i_
size
>>
5
)
&
0xff
;
out
->
p_buffer
[
15
]
=
(
(
in
->
i_
size
&
0xff
)
<<
3
)
|
0
;
out
->
p_buffer
[
14
]
=
(
in
->
i_
buffer
>>
5
)
&
0xff
;
out
->
p_buffer
[
15
]
=
(
(
in
->
i_
buffer
&
0xff
)
<<
3
)
|
0
;
memcpy
(
&
out
->
p_buffer
[
16
],
p_data
,
i_payload
);
out
->
i_
size
=
16
+
i_payload
;
out
->
i_
buffer
=
16
+
i_payload
;
out
->
i_dts
=
in
->
i_dts
+
i
*
in
->
i_length
/
i_count
;
out
->
i_length
=
in
->
i_length
/
i_count
;
...
...
modules/stream_out/standard.c
View file @
8547ffaa
...
...
@@ -2,7 +2,7 @@
* standard.c: standard stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
* $Id
: standard.c,v 1.18 2004/01/25 14:34:25 gbazin Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -42,7 +42,7 @@ static void Close ( vlc_object_t * );
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
/*****************************************************************************
* Module descriptor
...
...
@@ -290,9 +290,6 @@ static int Open( vlc_object_t *p_this )
}
#endif
/* XXX beurk */
p_sout
->
i_preheader
=
__MAX
(
p_sout
->
i_preheader
,
p_mux
->
i_preheader
);
p_stream
->
pf_add
=
Add
;
p_stream
->
pf_del
=
Del
;
p_stream
->
pf_send
=
Send
;
...
...
@@ -368,7 +365,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
}
static
int
Send
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
sout_instance_t
*
p_sout
=
p_stream
->
p_sout
;
...
...
modules/stream_out/transcode.c
View file @
8547ffaa
...
...
@@ -46,22 +46,33 @@
#endif
/*****************************************************************************
*
Exported prototypes
*
Module descriptor
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
vlc_module_begin
();
set_description
(
_
(
"Transcode stream output"
)
);
set_capability
(
"sout stream"
,
50
);
add_shortcut
(
"transcode"
);
set_callbacks
(
Open
,
Close
);
vlc_module_end
();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
static
int
transcode_audio_ffmpeg_new
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
void
transcode_audio_ffmpeg_close
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
transcode_audio_ffmpeg_process
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer_t
*
,
sout_buffer
_t
**
);
static
int
transcode_audio_ffmpeg_process
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block_t
*
,
block
_t
**
);
static
int
transcode_video_ffmpeg_new
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
void
transcode_video_ffmpeg_close
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
transcode_video_ffmpeg_process
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer_t
*
,
sout_buffer
_t
**
);
static
int
transcode_video_ffmpeg_process
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block_t
*
,
block
_t
**
);
static
int
transcode_video_ffmpeg_getframebuf
(
struct
AVCodecContext
*
,
AVFrame
*
);
...
...
@@ -78,16 +89,6 @@ static int pi_channels_maps[6] =
|
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
};
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_description
(
_
(
"Transcode stream output"
)
);
set_capability
(
"sout stream"
,
50
);
add_shortcut
(
"transcode"
);
set_callbacks
(
Open
,
Close
);
vlc_module_end
();
#define PICTURE_RING_SIZE 64
struct
sout_stream_sys_t
...
...
@@ -96,7 +97,7 @@ struct sout_stream_sys_t
sout_stream_t
*
p_out
;
sout_stream_id_t
*
id_video
;
sout_buffer
_t
*
p_buffers
;
block
_t
*
p_buffers
;
vlc_mutex_t
lock_out
;
vlc_cond_t
cond
;
picture_t
*
pp_pics
[
PICTURE_RING_SIZE
];
...
...
@@ -367,9 +368,6 @@ static int Open( vlc_object_t *p_this )
avcodec_init
();
avcodec_register_all
();
/* ffmpeg needs some padding at the end of each buffer */
p_stream
->
p_sout
->
i_padding
+=
FF_INPUT_BUFFER_PADDING_SIZE
;
return
VLC_SUCCESS
;
}
...
...
@@ -541,13 +539,23 @@ static int Del ( sout_stream_t *p_stream, sout_stream_id_t *id )
}
static
int
Send
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
if
(
id
->
b_transcode
)
{
sout_buffer_t
*
p_buffer_out
;
block_t
*
p_buffer_out
;
/* Be sure to have padding */
p_buffer
=
block_Realloc
(
p_buffer
,
0
,
p_buffer
->
i_buffer
+
FF_INPUT_BUFFER_PADDING_SIZE
);
if
(
p_buffer
==
NULL
)
{
return
VLC_EGENERIC
;
}
p_buffer
->
i_buffer
-=
FF_INPUT_BUFFER_PADDING_SIZE
;
memset
(
&
p_buffer
->
p_buffer
[
p_buffer
->
i_buffer
],
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
if
(
id
->
f_src
.
i_cat
==
AUDIO_ES
)
{
transcode_audio_ffmpeg_process
(
p_stream
,
id
,
p_buffer
,
...
...
@@ -558,11 +566,11 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
if
(
transcode_video_ffmpeg_process
(
p_stream
,
id
,
p_buffer
,
&
p_buffer_out
)
!=
VLC_SUCCESS
)
{
sout_BufferDelete
(
p_stream
->
p_sout
,
p_buffer
);
block_Release
(
p_buffer
);
return
VLC_EGENERIC
;
}
}
sout_BufferDelete
(
p_stream
->
p_sout
,
p_buffer
);
block_Release
(
p_buffer
);
if
(
p_buffer_out
)
{
...
...
@@ -576,7 +584,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
}
else
{
sout_BufferDelete
(
p_stream
->
p_sout
,
p_buffer
);
block_Release
(
p_buffer
);
return
VLC_EGENERIC
;
}
}
...
...
@@ -832,12 +840,12 @@ static void transcode_audio_ffmpeg_close( sout_stream_t *p_stream,
static
int
transcode_audio_ffmpeg_process
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
in
,
sout_buffer
_t
**
out
)
block
_t
*
in
,
block
_t
**
out
)
{
aout_buffer_t
aout_buf
;
block_t
*
p_block
;
int
i_buffer
=
in
->
i_
size
;
int
i_buffer
=
in
->
i_
buffer
;
char
*
p_buffer
=
in
->
p_buffer
;
id
->
i_dts
=
in
->
i_dts
;
*
out
=
NULL
;
...
...
@@ -947,14 +955,14 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream,
p_block
=
id
->
p_encoder
->
pf_header
(
id
->
p_encoder
);
while
(
p_block
)
{
sout_buffer
_t
*
p_out
;
block
_t
*
p_out
;
block_t
*
p_prev_block
=
p_block
;
p_out
=
sout_BufferNew
(
p_stream
->
p_sout
,
p_block
->
i_buffer
);
p_out
=
block_New
(
p_stream
,
p_block
->
i_buffer
);
memcpy
(
p_out
->
p_buffer
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
p_out
->
i_dts
=
p_out
->
i_pts
=
in
->
i_dts
;
p_out
->
i_length
=
0
;
sout_BufferChain
(
out
,
p_out
);
block_ChainAppend
(
out
,
p_out
);
p_block
=
p_block
->
p_next
;
block_Release
(
p_prev_block
);
...
...
@@ -1064,15 +1072,15 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream,
p_block
=
id
->
p_encoder
->
pf_encode_audio
(
id
->
p_encoder
,
&
aout_buf
);
while
(
p_block
)
{
sout_buffer
_t
*
p_out
;
block
_t
*
p_out
;
block_t
*
p_prev_block
=
p_block
;
p_out
=
sout_BufferNew
(
p_stream
->
p_sout
,
p_block
->
i_buffer
);
p_out
=
block_New
(
p_stream
,
p_block
->
i_buffer
);
memcpy
(
p_out
->
p_buffer
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
p_out
->
i_dts
=
p_block
->
i_dts
;
p_out
->
i_pts
=
p_block
->
i_pts
;
p_out
->
i_length
=
p_block
->
i_length
;
sout_BufferChain
(
out
,
p_out
);
block_ChainAppend
(
out
,
p_out
);
p_block
=
p_block
->
p_next
;
block_Release
(
p_prev_block
);
...
...
@@ -1200,25 +1208,6 @@ static int transcode_video_ffmpeg_new( sout_stream_t *p_stream,
msg_Err
(
p_stream
,
"cannot open decoder"
);
return
VLC_EGENERIC
;
}
#if 0
if( i_ff_codec == CODEC_ID_MPEG4 && id->ff_dec_c->extradata_size > 0 )
{
int b_gotpicture;
AVFrame frame;
uint8_t *p_vol = malloc( id->ff_dec_c->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE );
memcpy( p_vol, id->ff_dec_c->extradata,
id->ff_dec_c->extradata_size );
memset( p_vol + id->ff_dec_c->extradata_size, 0,
FF_INPUT_BUFFER_PADDING_SIZE );
avcodec_decode_video( id->ff_dec_c, &frame, &b_gotpicture,
id->ff_dec_c->extradata,
id->ff_dec_c->extradata_size );
free( p_vol );
}
#endif
}
/* Open encoder */
...
...
@@ -1382,7 +1371,7 @@ static void transcode_video_ffmpeg_close ( sout_stream_t *p_stream,
}
static
int
transcode_video_ffmpeg_process
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer_t
*
in
,
sout_buffer
_t
**
out
)
sout_stream_id_t
*
id
,
block_t
*
in
,
block
_t
**
out
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
int
i_used
;
...
...
@@ -1394,7 +1383,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
*
out
=
NULL
;
i_data
=
in
->
i_
size
;
i_data
=
in
->
i_
buffer
;
p_data
=
in
->
p_buffer
;
for
(
;;
)
...
...
@@ -1530,16 +1519,16 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
p_block
=
id
->
p_encoder
->
pf_header
(
id
->
p_encoder
);
while
(
p_block
)
{
sout_buffer
_t
*
p_out
;
block
_t
*
p_out
;
block_t
*
p_prev_block
=
p_block
;
p_out
=
sout_BufferNew
(
p_stream
->
p_sout
,
p_out
=
block_New
(
p_stream
,
p_block
->
i_buffer
);
memcpy
(
p_out
->
p_buffer
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
p_out
->
i_dts
=
p_out
->
i_pts
=
in
->
i_dts
;
p_out
->
i_length
=
0
;
sout_BufferChain
(
out
,
p_out
);
block_ChainAppend
(
out
,
p_out
);
p_block
=
p_block
->
p_next
;
block_Release
(
p_prev_block
);
...
...
@@ -1710,23 +1699,9 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
{
block_t
*
p_block
;
p_block
=
id
->
p_encoder
->
pf_encode_video
(
id
->
p_encoder
,
p_pic
);
while
(
p_block
)
if
(
p_block
)
{
sout_buffer_t
*
p_out
;
block_t
*
p_prev_block
=
p_block
;
p_out
=
sout_BufferNew
(
p_stream
->
p_sout
,
p_block
->
i_buffer
);
memcpy
(
p_out
->
p_buffer
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
p_out
->
i_dts
=
p_block
->
i_dts
;
p_out
->
i_pts
=
p_block
->
i_pts
;
p_out
->
i_length
=
p_block
->
i_length
;
p_out
->
i_flags
=
(
p_block
->
i_flags
<<
SOUT_BUFFER_FLAGS_BLOCK_SHIFT
)
&
SOUT_BUFFER_FLAGS_BLOCK_MASK
;
sout_BufferChain
(
out
,
p_out
);
p_block
=
p_block
->
p_next
;
block_Release
(
p_prev_block
);
block_ChainAppend
(
out
,
p_block
);
}
free
(
p_pic
);
}
...
...
@@ -1742,11 +1717,9 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
static
int
EncoderThread
(
sout_stream_sys_t
*
p_sys
)
{
sout_stream_t
*
p_stream
=
p_sys
->
p_out
;
sout_stream_id_t
*
id
=
p_sys
->
id_video
;
picture_t
*
p_pic
;
int
i_plane
;
sout_buffer_t
*
p_buffer
;
while
(
!
p_sys
->
b_die
&&
!
p_sys
->
b_error
)
{
...
...
@@ -1771,23 +1744,9 @@ static int EncoderThread( sout_stream_sys_t * p_sys )
p_block
=
id
->
p_encoder
->
pf_encode_video
(
id
->
p_encoder
,
p_pic
);
vlc_mutex_lock
(
&
p_sys
->
lock_out
);
while
(
p_block
)
if
(
p_block
)
{
sout_buffer_t
*
p_out
;
block_t
*
p_prev_block
=
p_block
;
p_out
=
sout_BufferNew
(
p_stream
->
p_sout
,
p_block
->
i_buffer
);
memcpy
(
p_out
->
p_buffer
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
p_out
->
i_dts
=
p_block
->
i_dts
;
p_out
->
i_pts
=
p_block
->
i_pts
;
p_out
->
i_length
=
p_block
->
i_length
;
p_out
->
i_flags
=
(
p_block
->
i_flags
<<
SOUT_BUFFER_FLAGS_BLOCK_SHIFT
)
&
SOUT_BUFFER_FLAGS_BLOCK_MASK
;
sout_BufferChain
(
&
p_sys
->
p_buffers
,
p_out
);
p_block
=
p_block
->
p_next
;
block_Release
(
p_prev_block
);
block_ChainAppend
(
&
p_sys
->
p_buffers
,
p_block
);
}
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
...
...
@@ -1810,13 +1769,7 @@ static int EncoderThread( sout_stream_sys_t * p_sys )
free
(
p_pic
);
}
p_buffer
=
p_sys
->
p_buffers
;
while
(
p_buffer
!=
NULL
)
{
sout_buffer_t
*
p_next
=
p_buffer
->
p_next
;
sout_BufferDelete
(
p_stream
->
p_sout
,
p_buffer
);
p_buffer
=
p_next
;
}
block_ChainRelease
(
p_sys
->
p_buffers
);
return
0
;
}
...
...
modules/stream_out/transrate/frame.c
View file @
8547ffaa
...
...
@@ -5,7 +5,7 @@
* Copyright (C) 2003 Antoine Missout
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* $Id
: frame.c,v 1.2 2004/03/03 11:39:06 massiot Exp
$
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
...
...
@@ -1636,56 +1636,56 @@ static int do_next_start_code( transrate_t *tr )
}
void
E_
(
process_frame
)(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer_t
*
in
,
sout_buffer
_t
**
out
)
sout_stream_id_t
*
id
,
block_t
*
in
,
block
_t
**
out
)
{
transrate_t
*
tr
=
&
id
->
tr
;
bs_transrate_t
*
bs
=
&
tr
->
bs
;
sout_buffer
_t
*
p_out
;
block
_t
*
p_out
;
double
next_fact_x
=
1
.
0
;
/* The output buffer can't be bigger than the input buffer. */
p_out
=
sout_BufferNew
(
p_stream
->
p_sout
,
in
->
i_size
);
p_out
=
block_New
(
p_stream
,
in
->
i_buffer
);
p_out
->
i_length
=
in
->
i_length
;
p_out
->
i_dts
=
in
->
i_dts
;
p_out
->
i_pts
=
in
->
i_pts
;
p_out
->
i_flags
=
in
->
i_flags
;
sout_BufferChain
(
out
,
p_out
);
block_ChainAppend
(
out
,
p_out
);
bs
->
p_rw
=
bs
->
p_ow
=
bs
->
p_w
=
p_out
->
p_buffer
;
bs
->
p_c
=
bs
->
p_r
=
in
->
p_buffer
;
bs
->
p_r
+=
in
->
i_
size
+
4
;
bs
->
p_rw
+=
in
->
i_
size
;
*
(
in
->
p_buffer
+
in
->
i_
size
)
=
0
;
*
(
in
->
p_buffer
+
in
->
i_
size
+
1
)
=
0
;
*
(
in
->
p_buffer
+
in
->
i_
size
+
2
)
=
1
;
*
(
in
->
p_buffer
+
in
->
i_
size
+
3
)
=
0
;
bs
->
p_r
+=
in
->
i_
buffer
+
4
;
bs
->
p_rw
+=
in
->
i_
buffer
;
*
(
in
->
p_buffer
+
in
->
i_
buffer
)
=
0
;
*
(
in
->
p_buffer
+
in
->
i_
buffer
+
1
)
=
0
;
*
(
in
->
p_buffer
+
in
->
i_
buffer
+
2
)
=
1
;
*
(
in
->
p_buffer
+
in
->
i_
buffer
+
3
)
=
0
;
/* Calculate how late we are */
tr
->
quant_corr
=
0
.
0
+
B_HANDICAP
;
tr
->
level_i
=
0
;
tr
->
level_p
=
0
;
bs
->
i_byte_in
=
in
->
i_
size
;
bs
->
i_byte_in
=
in
->
i_
buffer
;
bs
->
i_byte_out
=
0
;
if
(
tr
->
i_current_gop_size
-
in
->
i_
size
>
100
)
if
(
tr
->
i_current_gop_size
-
in
->
i_
buffer
>
100
)
{
if
(
tr
->
i_wanted_gop_size
==
in
->
i_
size
)
if
(
tr
->
i_wanted_gop_size
==
in
->
i_
buffer
)
{
next_fact_x
=
1
.
0
;
}
else
if
(
tr
->
i_wanted_gop_size
<
in
->
i_
size
)
else
if
(
tr
->
i_wanted_gop_size
<
in
->
i_
buffer
)
{
/* We're really late */
next_fact_x
=
10
.
0
;
}
else
{
next_fact_x
=
((
double
)(
tr
->
i_current_gop_size
-
in
->
i_
size
))
/
(
tr
->
i_wanted_gop_size
-
in
->
i_
size
);
next_fact_x
=
((
double
)(
tr
->
i_current_gop_size
-
in
->
i_
buffer
))
/
(
tr
->
i_wanted_gop_size
-
in
->
i_
buffer
);
}
if
(
next_fact_x
>
QUANT_I
)
...
...
@@ -1710,7 +1710,7 @@ void E_(process_frame)( sout_stream_t *p_stream,
for
(
;
;
)
{
uint8_t
*
p_end
=
&
in
->
p_buffer
[
in
->
i_
size
];
uint8_t
*
p_end
=
&
in
->
p_buffer
[
in
->
i_
buffer
];
/* Search next start code */
for
(
;;
)
...
...
@@ -1759,15 +1759,15 @@ void E_(process_frame)( sout_stream_t *p_stream,
}
bs
->
i_byte_out
+=
bs
->
p_w
-
bs
->
p_ow
;
p_out
->
i_
size
=
bs
->
p_w
-
bs
->
p_ow
;
tr
->
i_current_gop_size
-=
in
->
i_
size
;
tr
->
i_wanted_gop_size
-=
p_out
->
i_
size
;
p_out
->
i_
buffer
=
bs
->
p_w
-
bs
->
p_ow
;
tr
->
i_current_gop_size
-=
in
->
i_
buffer
;
tr
->
i_wanted_gop_size
-=
p_out
->
i_
buffer
;
tr
->
i_new_gop_size
+=
bs
->
i_byte_out
;
#if 0
msg_Dbg( p_stream, "%d: %d -> %d (r: %f, n:%f, corr:%f)",
tr->picture_coding_type, in->i_
size
, p_out->i_size,
(float)in->i_
size
/ p_out->i_size,
tr->picture_coding_type, in->i_
buffer
, p_out->i_size,
(float)in->i_
buffer
/ p_out->i_size,
next_fact_x, tr->quant_corr);
#endif
}
...
...
modules/stream_out/transrate/transrate.c
View file @
8547ffaa
...
...
@@ -2,7 +2,7 @@
* transrate.c: MPEG2 video transrating module
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id
: transrate.c,v 1.7 2004/03/03 11:20:52 massiot Exp
$
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
...
...
@@ -45,12 +45,12 @@ static void Close ( vlc_object_t * );
static
sout_stream_id_t
*
Add
(
sout_stream_t
*
,
es_format_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer
_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block
_t
*
);
static
int
transrate_video_process
(
sout_stream_t
*
,
sout_stream_id_t
*
,
sout_buffer_t
*
,
sout_buffer
_t
**
);
static
int
transrate_video_process
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block_t
*
,
block
_t
**
);
void
E_
(
process_frame
)(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer_t
*
in
,
sout_buffer
_t
**
out
);
sout_stream_id_t
*
id
,
block_t
*
in
,
block
_t
**
out
);
/*****************************************************************************
* Module descriptor
...
...
@@ -130,8 +130,6 @@ static int Open( vlc_object_t *p_this )
p_stream
->
p_sys
=
p_sys
;
p_stream
->
p_sout
->
i_padding
+=
200
;
return
VLC_SUCCESS
;
}
...
...
@@ -205,13 +203,18 @@ static int Del ( sout_stream_t *p_stream, sout_stream_id_t *id )
}
static
int
Send
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer
_t
*
p_buffer
)
block
_t
*
p_buffer
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
if
(
id
->
b_transrate
)
{
sout_buffer_t
*
p_buffer_out
;
block_t
*
p_buffer_out
;
/* be sure to have at least 8 bytes of padding (maybe only 4) */
p_buffer
=
block_Realloc
(
p_buffer
,
0
,
p_buffer
->
i_buffer
+
8
);
p_buffer
->
i_buffer
-=
8
;
memset
(
&
p_buffer
->
p_buffer
[
p_buffer
->
i_buffer
],
0
,
8
);
transrate_video_process
(
p_stream
,
id
,
p_buffer
,
&
p_buffer_out
);
if
(
p_buffer_out
)
...
...
@@ -226,13 +229,13 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
}
else
{
sout_BufferDelete
(
p_stream
->
p_sout
,
p_buffer
);
block_Release
(
p_buffer
);
return
VLC_EGENERIC
;
}
}
static
int
transrate_video_process
(
sout_stream_t
*
p_stream
,
sout_stream_id_t
*
id
,
sout_buffer_t
*
in
,
sout_buffer
_t
**
out
)
sout_stream_id_t
*
id
,
block_t
*
in
,
block
_t
**
out
)
{
transrate_t
*
tr
=
&
id
->
tr
;
bs_transrate_t
*
bs
=
&
tr
->
bs
;
...
...
@@ -241,16 +244,16 @@ static int transrate_video_process( sout_stream_t *p_stream,
while
(
in
!=
NULL
)
{
sout_buffer
_t
*
p_next
=
in
->
p_next
;
block
_t
*
p_next
=
in
->
p_next
;
int
i_flags
=
in
->
i_flags
;
in
->
p_next
=
NULL
;
sout_BufferChain
(
&
id
->
p_next_gop
,
in
);
block_ChainAppend
(
&
id
->
p_next_gop
,
in
);
id
->
i_next_gop_duration
+=
in
->
i_length
;
id
->
i_next_gop_size
+=
in
->
i_
size
;
id
->
i_next_gop_size
+=
in
->
i_
buffer
;
in
=
p_next
;
if
(
((
i_flags
&
(
BLOCK_FLAG_TYPE_I
<<
SOUT_BUFFER_FLAGS_BLOCK_SHIFT
)
)
if
(
((
i_flags
&
BLOCK_FLAG_TYPE_I
)
&&
id
->
i_next_gop_duration
>=
300000
)
||
(
id
->
i_next_gop_duration
>
p_stream
->
p_sys
->
i_shaping_delay
)
)
{
...
...
@@ -275,17 +278,17 @@ static int transrate_video_process( sout_stream_t *p_stream,
while
(
id
->
p_current_buffer
!=
NULL
)
{
sout_buffer
_t
*
p_next
=
id
->
p_current_buffer
->
p_next
;
block
_t
*
p_next
=
id
->
p_current_buffer
->
p_next
;
if
(
tr
->
fact_x
==
1
.
0
)
{
bs
->
i_byte_out
+=
id
->
p_current_buffer
->
i_
size
;
bs
->
i_byte_out
+=
id
->
p_current_buffer
->
i_
buffer
;
id
->
p_current_buffer
->
p_next
=
NULL
;
sout_BufferChain
(
out
,
id
->
p_current_buffer
);
block_ChainAppend
(
out
,
id
->
p_current_buffer
);
}
else
{
E_
(
process_frame
)(
p_stream
,
id
,
id
->
p_current_buffer
,
out
);
sout_BufferDelete
(
p_stream
->
p_sout
,
id
->
p_current_buffer
);
block_Release
(
id
->
p_current_buffer
);
}
id
->
p_current_buffer
=
p_next
;
}
...
...
modules/stream_out/transrate/transrate.h
View file @
8547ffaa
...
...
@@ -5,7 +5,7 @@
* Copyright (C) 2003 Antoine Missout
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* $Id
: transrate.h,v 1.1 2004/03/03 11:20:52 massiot Exp
$
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
...
...
@@ -98,8 +98,8 @@ struct sout_stream_id_t
void
*
id
;
vlc_bool_t
b_transrate
;
sout_buffer
_t
*
p_current_buffer
;
sout_buffer
_t
*
p_next_gop
;
block
_t
*
p_current_buffer
;
block
_t
*
p_next_gop
;
mtime_t
i_next_gop_duration
;
size_t
i_next_gop_size
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment