| 2153 | } |
| 2154 | |
| 2155 | static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in, |
| 2156 | hb_buffer_t ** buf_out ) |
| 2157 | { |
| 2158 | hb_work_private_t * pv = w->private_data; |
| 2159 | hb_buffer_t * in = *buf_in; |
| 2160 | int result = HB_WORK_OK; |
| 2161 | |
| 2162 | *buf_out = NULL; |
| 2163 | |
| 2164 | // libavcodec/mpeg12dec.c requires buffers to be zero padded. |
| 2165 | // If not zero padded, it can get stuck in an infinite loop. |
| 2166 | // It's likely there are other decoders that expect the same. |
| 2167 | if (in->data != NULL) |
| 2168 | { |
| 2169 | memset(in->data + in->size, 0, in->alloc - in->size); |
| 2170 | } |
| 2171 | if (in->palette != NULL) |
| 2172 | { |
| 2173 | pv->palette = in->palette; |
| 2174 | in->palette = NULL; |
| 2175 | } |
| 2176 | |
| 2177 | /* if we got an empty buffer signaling end-of-stream send it downstream */ |
| 2178 | if (in->s.flags & HB_BUF_FLAG_EOF) |
| 2179 | { |
| 2180 | if (pv->context != NULL && pv->context->codec != NULL) |
| 2181 | { |
| 2182 | videoParserFlush(w); |
| 2183 | while (decodeFrame(pv, NULL)) |
| 2184 | { |
| 2185 | continue; |
| 2186 | } |
| 2187 | } |
| 2188 | hb_buffer_list_append(&pv->list, hb_buffer_dup(in)); |
| 2189 | *buf_out = hb_buffer_list_clear(&pv->list); |
| 2190 | return HB_WORK_DONE; |
| 2191 | } |
| 2192 | |
| 2193 | /* |
| 2194 | * The following loop is a do..while because we need to handle both |
| 2195 | * data & the flush at the end (signaled by size=0). At the end there's |
| 2196 | * generally a frame in the parser & one or more frames in the decoder |
| 2197 | * (depending on the bframes setting). |
| 2198 | */ |
| 2199 | int pos, len; |
| 2200 | int64_t pts = in->s.start; |
| 2201 | int64_t dts = in->s.renderOffset; |
| 2202 | |
| 2203 | if (in->s.new_chap > 0) |
| 2204 | { |
| 2205 | pv->new_chap = in->s.new_chap; |
| 2206 | pv->chap_scr = in->s.scr_sequence; |
| 2207 | if (in->s.start != AV_NOPTS_VALUE) |
| 2208 | { |
| 2209 | pv->chap_time = in->s.start; |
| 2210 | } |
| 2211 | else |
| 2212 | { |
nothing calls this directly
no test coverage detected