Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
fbb59a3b
Commit
fbb59a3b
authored
Jun 14, 2014
by
Anshul Maheshwari
Committed by
Michael Niedermayer
Jun 15, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/dvbsubdec: Split save_subtitle_set() out
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
77ade55f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
78 deletions
+81
-78
dvbsubdec.c
libavcodec/dvbsubdec.c
+81
-78
No files found.
libavcodec/dvbsubdec.c
View file @
fbb59a3b
...
...
@@ -759,7 +759,85 @@ static int dvbsub_read_8bit_string(uint8_t *destbuf, int dbuf_len,
return
pixels_read
;
}
static
void
save_subtitle_set
(
AVCodecContext
*
avctx
,
AVSubtitle
*
sub
)
{
DVBSubContext
*
ctx
=
avctx
->
priv_data
;
DVBSubRegionDisplay
*
display
;
DVBSubDisplayDefinition
*
display_def
=
ctx
->
display_definition
;
DVBSubRegion
*
region
;
AVSubtitleRect
*
rect
;
DVBSubCLUT
*
clut
;
uint32_t
*
clut_table
;
int
i
;
int
offset_x
=
0
,
offset_y
=
0
;
sub
->
end_display_time
=
ctx
->
time_out
*
1000
;
if
(
display_def
)
{
offset_x
=
display_def
->
x
;
offset_y
=
display_def
->
y
;
}
sub
->
num_rects
=
0
;
for
(
display
=
ctx
->
display_list
;
display
;
display
=
display
->
next
)
{
region
=
get_region
(
ctx
,
display
->
region_id
);
if
(
region
&&
region
->
dirty
)
sub
->
num_rects
++
;
}
if
(
sub
->
num_rects
>
0
)
{
sub
->
rects
=
av_mallocz_array
(
sizeof
(
*
sub
->
rects
),
sub
->
num_rects
);
for
(
i
=
0
;
i
<
sub
->
num_rects
;
i
++
)
sub
->
rects
[
i
]
=
av_mallocz
(
sizeof
(
*
sub
->
rects
[
i
]));
i
=
0
;
for
(
display
=
ctx
->
display_list
;
display
;
display
=
display
->
next
)
{
region
=
get_region
(
ctx
,
display
->
region_id
);
if
(
!
region
)
continue
;
if
(
!
region
->
dirty
)
continue
;
rect
=
sub
->
rects
[
i
];
rect
->
x
=
display
->
x_pos
+
offset_x
;
rect
->
y
=
display
->
y_pos
+
offset_y
;
rect
->
w
=
region
->
width
;
rect
->
h
=
region
->
height
;
rect
->
nb_colors
=
(
1
<<
region
->
depth
);
rect
->
type
=
SUBTITLE_BITMAP
;
rect
->
pict
.
linesize
[
0
]
=
region
->
width
;
clut
=
get_clut
(
ctx
,
region
->
clut
);
if
(
!
clut
)
clut
=
&
default_clut
;
switch
(
region
->
depth
)
{
case
2
:
clut_table
=
clut
->
clut4
;
break
;
case
8
:
clut_table
=
clut
->
clut256
;
break
;
case
4
:
default:
clut_table
=
clut
->
clut16
;
break
;
}
rect
->
pict
.
data
[
1
]
=
av_mallocz
(
AVPALETTE_SIZE
);
memcpy
(
rect
->
pict
.
data
[
1
],
clut_table
,
(
1
<<
region
->
depth
)
*
sizeof
(
uint32_t
));
rect
->
pict
.
data
[
0
]
=
av_malloc
(
region
->
buf_size
);
memcpy
(
rect
->
pict
.
data
[
0
],
region
->
pbuf
,
region
->
buf_size
);
i
++
;
}
}
}
static
void
dvbsub_parse_pixel_data_block
(
AVCodecContext
*
avctx
,
DVBSubObjectDisplay
*
display
,
const
uint8_t
*
buf
,
int
buf_size
,
int
top_bottom
,
int
non_mod
)
...
...
@@ -1150,7 +1228,7 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
}
static
void
dvbsub_parse_page_segment
(
AVCodecContext
*
avctx
,
const
uint8_t
*
buf
,
int
buf_size
)
const
uint8_t
*
buf
,
int
buf_size
,
AVSubtitle
*
sub
)
{
DVBSubContext
*
ctx
=
avctx
->
priv_data
;
DVBSubRegionDisplay
*
display
;
...
...
@@ -1371,83 +1449,8 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,
int
buf_size
,
AVSubtitle
*
sub
)
{
DVBSubContext
*
ctx
=
avctx
->
priv_data
;
DVBSubDisplayDefinition
*
display_def
=
ctx
->
display_definition
;
DVBSubRegion
*
region
;
DVBSubRegionDisplay
*
display
;
AVSubtitleRect
*
rect
;
DVBSubCLUT
*
clut
;
uint32_t
*
clut_table
;
int
i
;
int
offset_x
=
0
,
offset_y
=
0
;
sub
->
end_display_time
=
ctx
->
time_out
*
1000
;
if
(
display_def
)
{
offset_x
=
display_def
->
x
;
offset_y
=
display_def
->
y
;
}
sub
->
num_rects
=
0
;
for
(
display
=
ctx
->
display_list
;
display
;
display
=
display
->
next
)
{
region
=
get_region
(
ctx
,
display
->
region_id
);
if
(
region
&&
region
->
dirty
)
sub
->
num_rects
++
;
}
if
(
sub
->
num_rects
>
0
){
sub
->
rects
=
av_mallocz_array
(
sizeof
(
*
sub
->
rects
),
sub
->
num_rects
);
for
(
i
=
0
;
i
<
sub
->
num_rects
;
i
++
)
sub
->
rects
[
i
]
=
av_mallocz
(
sizeof
(
*
sub
->
rects
[
i
]));
i
=
0
;
for
(
display
=
ctx
->
display_list
;
display
;
display
=
display
->
next
)
{
region
=
get_region
(
ctx
,
display
->
region_id
);
if
(
!
region
)
continue
;
if
(
!
region
->
dirty
)
continue
;
rect
=
sub
->
rects
[
i
];
rect
->
x
=
display
->
x_pos
+
offset_x
;
rect
->
y
=
display
->
y_pos
+
offset_y
;
rect
->
w
=
region
->
width
;
rect
->
h
=
region
->
height
;
rect
->
nb_colors
=
(
1
<<
region
->
depth
);
rect
->
type
=
SUBTITLE_BITMAP
;
rect
->
pict
.
linesize
[
0
]
=
region
->
width
;
clut
=
get_clut
(
ctx
,
region
->
clut
);
if
(
!
clut
)
clut
=
&
default_clut
;
switch
(
region
->
depth
)
{
case
2
:
clut_table
=
clut
->
clut4
;
break
;
case
8
:
clut_table
=
clut
->
clut256
;
break
;
case
4
:
default:
clut_table
=
clut
->
clut16
;
break
;
}
rect
->
pict
.
data
[
1
]
=
av_mallocz
(
AVPALETTE_SIZE
);
memcpy
(
rect
->
pict
.
data
[
1
],
clut_table
,
(
1
<<
region
->
depth
)
*
sizeof
(
uint32_t
));
rect
->
pict
.
data
[
0
]
=
av_malloc
(
region
->
buf_size
);
memcpy
(
rect
->
pict
.
data
[
0
],
region
->
pbuf
,
region
->
buf_size
);
i
++
;
}
}
save_subtitle_set
(
avctx
,
sub
);
#ifdef DEBUG
save_display_set
(
ctx
);
#endif
...
...
@@ -1511,7 +1514,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
ctx
->
composition_id
==
-
1
||
ctx
->
ancillary_id
==
-
1
)
{
switch
(
segment_type
)
{
case
DVBSUB_PAGE_SEGMENT
:
dvbsub_parse_page_segment
(
avctx
,
p
,
segment_length
);
dvbsub_parse_page_segment
(
avctx
,
p
,
segment_length
,
sub
);
got_segment
|=
1
;
break
;
case
DVBSUB_REGION_SEGMENT
:
...
...
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