| 1909 | } |
| 1910 | |
| 1911 | int CFFDecoder::flush(Task &task) { |
| 1912 | AVPacket fpkt; |
| 1913 | int got_frame; |
| 1914 | av_init_packet(&fpkt); |
| 1915 | int ret; |
| 1916 | |
| 1917 | if (video_stream_index_ != -1) { |
| 1918 | fpkt.stream_index = video_stream_index_; |
| 1919 | while (1) { |
| 1920 | fpkt.data = NULL; |
| 1921 | fpkt.size = 0; |
| 1922 | if (check_valid_packet( |
| 1923 | &fpkt, task)) { // output q may not exist and won't process |
| 1924 | ret = decode_send_packet(task, &fpkt, &got_frame); |
| 1925 | if (ret < 0) { |
| 1926 | if (ret == AVERROR_EOF) |
| 1927 | break; |
| 1928 | if (ret != AVERROR(EAGAIN)) { |
| 1929 | std::string msg = error_msg(ret); |
| 1930 | BMFLOG_NODE(BMF_ERROR, node_id_) |
| 1931 | << "flush decode video error: " << msg; |
| 1932 | } |
| 1933 | } |
| 1934 | } else |
| 1935 | break; |
| 1936 | } |
| 1937 | } |
| 1938 | |
| 1939 | if (audio_stream_index_ != -1) { |
| 1940 | fpkt.stream_index = audio_stream_index_; |
| 1941 | while (1) { |
| 1942 | fpkt.data = NULL; |
| 1943 | fpkt.size = 0; |
| 1944 | if (check_valid_packet(&fpkt, task)) { |
| 1945 | ret = decode_send_packet(task, &fpkt, &got_frame); |
| 1946 | if (ret < 0) { |
| 1947 | if (ret == AVERROR_EOF) |
| 1948 | break; |
| 1949 | if (ret != AVERROR(EAGAIN)) { |
| 1950 | std::string msg = error_msg(ret); |
| 1951 | BMFLOG_NODE(BMF_ERROR, node_id_) |
| 1952 | << "flush decode audio error" << msg; |
| 1953 | break; |
| 1954 | } |
| 1955 | } |
| 1956 | } else |
| 1957 | break; |
| 1958 | } |
| 1959 | } |
| 1960 | |
| 1961 | BMFLOG_NODE(BMF_INFO, node_id_) << "decode flushing"; |
| 1962 | if (!audio_end_) { |
| 1963 | handle_output_data(task, 1, NULL, true, false, got_frame); |
| 1964 | audio_end_ = true; |
| 1965 | } |
| 1966 | if (!video_end_) { |
| 1967 | handle_output_data(task, 0, NULL, true, false, got_frame); |
| 1968 | video_end_ = true; |
no test coverage detected