History

Add avsubtitle_free function.

Originally committed as revision 24185 to svn://svn.ffmpeg.org/ffmpeg/trunk

Reimar Döffinger committed 16 years ago

Commit e1d7c881 parent c4265624 files · +36 −14Browse files

Unified · Split

4 files
  1. doc/APIchanges +4 −0
  2. ffplay.c +1 −12
  3. libavcodec/avcodec.h +11 −2
  4. libavcodec/utils.c +20 −0
doc/APIchanges+4−0
@@ -12,6 +12,10 @@ libavutil: 2009-03-08 · 11 unmodified lines
1212
1313 API changes, most recent first:
1414
15+2010-07-11 - r24185 - lavc 52.82.0 - avsubtitle_free()
16+ Add a function for free the contents of a AVSubtitle generated by
17+ avcodec_decode_subtitle.
18+
1519 2010-07-08 - r24101 - lavu 50.21.0 - pixdesc.h
1620 Rename read/write_line() to av_read/write_image_line().
1721
ffplay.c+1−12
@@ -677,18 +677,7 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, · 676 unmodified lines
677677
678678 static void free_subpicture(SubPicture *sp)
679679 {
680− int i;
681−
682− for (i = 0; i < sp->sub.num_rects; i++)
683− {
684− av_freep(&sp->sub.rects[i]->pict.data[0]);
685− av_freep(&sp->sub.rects[i]->pict.data[1]);
686− av_freep(&sp->sub.rects[i]);
687− }
688−
689− av_free(sp->sub.rects);
690−
691− memset(&sp->sub, 0, sizeof(AVSubtitle));
680+ avsubtitle_free(&sp->sub);
692681 }
693682
694683 static void video_image_display(VideoState *is)
libavcodec/avcodec.h+11−2
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/avutil.h"
3131
3232 #define LIBAVCODEC_VERSION_MAJOR 52
33−#define LIBAVCODEC_VERSION_MINOR 81
33+#define LIBAVCODEC_VERSION_MINOR 82
3434 #define LIBAVCODEC_VERSION_MICRO 0
3535
3636 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -3548,13 +3548,22 @@ attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtit · 3511 unmodified lines
35483548 * due to a potentially very different allocation pattern.
35493549 *
35503550 * @param avctx the codec context
3551− * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored.
3551+ * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
3552+ freed with avsubtitle_free if *got_sub_ptr is set.
35523553 * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
35533554 * @param[in] avpkt The input AVPacket containing the input buffer.
35543555 */
35553556 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
35563557 int *got_sub_ptr,
35573558 AVPacket *avpkt);
3559+
3560+/**
3561+ * Frees all allocated data in the given subtitle struct.
3562+ *
3563+ * @param sub AVSubtitle to free.
3564+ */
3565+void avsubtitle_free(AVSubtitle *sub);
3566+
35583567 int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
35593568 int *data_size_ptr,
35603569 uint8_t *buf, int buf_size);
libavcodec/utils.c+20−0
@@ -689,6 +689,26 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, · 688 unmodified lines
689689 return ret;
690690 }
691691
692+void avsubtitle_free(AVSubtitle *sub)
693+{
694+ int i;
695+
696+ for (i = 0; i < sub->num_rects; i++)
697+ {
698+ av_freep(sub->rects[i]->pict.data[0]);
699+ av_freep(sub->rects[i]->pict.data[1]);
700+ av_freep(sub->rects[i]->pict.data[2]);
701+ av_freep(sub->rects[i]->pict.data[3]);
702+ av_freep(sub->rects[i]->text);
703+ av_freep(sub->rects[i]->ass);
704+ av_freep(sub->rects[i]);
705+ }
706+
707+ av_freep(sub->rects);
708+
709+ memset(sub, 0, sizeof(AVSubtitle));
710+}
711+
692712 av_cold int avcodec_close(AVCodecContext *avctx)
693713 {
694714 /* If there is a user-supplied mutex locking routine, call it. */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t