return 0;
return buf_size;
static int dvbsub_decode(AVCodecContext *avctx,                         void *data, int *data_size,                         uint8_t *buf, int buf_size){    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;    AVSubtitle *sub = (AVSubtitle*) data;    uint8_t *p, *p_end;    int segment_type;    int page_id;    int segment_length;  #ifdef DEBUG_PACKET_CONTENTS    int i;    av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n");    for (i=0; i < buf_size; i++)    {        av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);        if (i % 16 == 15)            av_log(avctx, AV_LOG_INFO, "\n");    }        if (i % 16 != 0)        av_log(avctx, AV_LOG_INFO, "\n");#endif    if (buf_size <= 2)        return -1;            p = buf;    p_end = buf + buf_size;            while (p < p_end && *p == 0x0f)    {        p += 1;        segment_type = *p++;        page_id = BE_16(p);        p += 2;        segment_length = BE_16(p);        p += 2;                if (page_id == ctx->composition_id || page_id == ctx->ancillary_id) {            switch (segment_type) {            case DVBSUB_PAGE_SEGMENT:                dvbsub_parse_page_segment(avctx, p, segment_length);                break;            case DVBSUB_REGION_SEGMENT:                dvbsub_parse_region_segment(avctx, p, segment_length);                break;            case DVBSUB_CLUT_SEGMENT:                dvbsub_parse_clut_segment(avctx, p, segment_length);                break;            case DVBSUB_OBJECT_SEGMENT:                dvbsub_parse_object_segment(avctx, p, segment_length);                break;            case DVBSUB_DISPLAY_SEGMENT:                *data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub);                break;            default:#ifdef DEBUG                av_log(avctx, AV_LOG_INFO, "Subtitling segment type 0x%x, page id %d, length %d\n",                         segment_type, page_id, segment_length);#endif                break;            }        }        p += segment_length;    }        if (p != p_end)    {#ifdef DEBUG        av_log(avctx, AV_LOG_INFO, "Junk at end of packet\n");#endif        return -1;    }    return 0;}